]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #5229 from rabuzarus/20180616_-_fix_stream_position_ajax_update
authorHypolite Petovan <mrpetovan@gmail.com>
Sat, 16 Jun 2018 13:06:32 +0000 (09:06 -0400)
committerGitHub <noreply@github.com>
Sat, 16 Jun 2018 13:06:32 +0000 (09:06 -0400)
fix scroll position in stream while ajax update

14 files changed:
composer.json
composer.lock
mod/update_community.php
mod/update_display.php
mod/update_network.php
mod/update_notes.php
mod/update_profile.php
view/js/main.js
view/templates/head.tpl
view/theme/frio/templates/head.tpl
view/theme/quattro/templates/search_item.tpl
view/theme/quattro/templates/wall_thread.tpl
view/theme/vier/templates/search_item.tpl
view/theme/vier/templates/wall_thread.tpl

index 9668b9341c14e819a1f267fd4cd7d314d3742261..941464e70c78ad45b470d0c46d274a599b5197e3 100644 (file)
@@ -37,7 +37,8 @@
                "npm-asset/jquery-datetimepicker": "^2.4.0",
                "npm-asset/jgrowl": "^1.4",
                "npm-asset/fullcalendar": "^3.0.1",
-               "npm-asset/cropperjs": "1.2.2"
+               "npm-asset/cropperjs": "1.2.2",
+               "npm-asset/imagesloaded": "4.1.4"
        },
        "repositories": [
                {
index dd2665ebbe251b4dffa61f87ea267c1d2c1eaa2a..7ba8fc1cfd1f8000f2f608fb16e0f154464d75bb 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "ab5a551aff0505691c4836d063fc5171",
+    "content-hash": "4fcae78061a3eb72f91e4fa81e53af56",
     "packages": [
         {
             "name": "asika/simple-console",
             ],
             "time": "2018-01-03T13:39:39+00:00"
         },
+        {
+            "name": "npm-asset/ev-emitter",
+            "version": "1.1.1",
+            "dist": {
+                "type": "tar",
+                "url": "https://registry.npmjs.org/ev-emitter/-/ev-emitter-1.1.1.tgz",
+                "reference": null,
+                "shasum": "8f18b0ce5c76a5d18017f71c0a795c65b9138f2a"
+            },
+            "type": "npm-asset-library",
+            "extra": {
+                "npm-asset-bugs": {
+                    "url": "https://github.com/metafizzy/ev-emitter/issues"
+                },
+                "npm-asset-main": "ev-emitter.js",
+                "npm-asset-directories": {
+                    "test": "test"
+                },
+                "npm-asset-repository": {
+                    "type": "git",
+                    "url": "git+https://github.com/metafizzy/ev-emitter.git"
+                },
+                "npm-asset-scripts": {
+                    "test": "mocha test/test"
+                }
+            },
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "David DeSandro"
+                }
+            ],
+            "description": "lil' event emitter",
+            "homepage": "https://github.com/metafizzy/ev-emitter#readme",
+            "keywords": [
+                "emitter",
+                "event",
+                "pubsub"
+            ],
+            "time": "2017-07-06T13:46:38+00:00"
+        },
         {
             "name": "npm-asset/fullcalendar",
             "version": "3.8.2",
             ],
             "time": "2018-01-30T23:49:01+00:00"
         },
+        {
+            "name": "npm-asset/imagesloaded",
+            "version": "4.1.4",
+            "dist": {
+                "type": "tar",
+                "url": "https://registry.npmjs.org/imagesloaded/-/imagesloaded-4.1.4.tgz",
+                "reference": null,
+                "shasum": "1376efcd162bb768c34c3727ac89cc04051f3cc7"
+            },
+            "require": {
+                "npm-asset/ev-emitter": ">=1.0.0,<2.0.0"
+            },
+            "require-dev": {
+                "npm-asset/chalk": ">=1.1.1,<2.0.0",
+                "npm-asset/cheerio": ">=0.19.0,<0.20.0",
+                "npm-asset/gulp": ">=3.9.0,<4.0.0",
+                "npm-asset/gulp-jshint": ">=1.11.2,<2.0.0",
+                "npm-asset/gulp-json-lint": ">=0.1.0,<0.2.0",
+                "npm-asset/gulp-rename": ">=1.2.2,<2.0.0",
+                "npm-asset/gulp-replace": ">=0.5.4,<0.6.0",
+                "npm-asset/gulp-requirejs-optimize": "dev-github:metafizzy/gulp-requirejs-optimize",
+                "npm-asset/gulp-uglify": ">=1.4.2,<2.0.0",
+                "npm-asset/gulp-util": ">=3.0.7,<4.0.0",
+                "npm-asset/highlight.js": ">=8.9.1,<9.0.0",
+                "npm-asset/marked": ">=0.3.5,<0.4.0",
+                "npm-asset/minimist": ">=1.2.0,<2.0.0",
+                "npm-asset/transfob": ">=1.0.0,<2.0.0"
+            },
+            "type": "npm-asset-library",
+            "extra": {
+                "npm-asset-bugs": {
+                    "url": "https://github.com/desandro/imagesloaded/issues"
+                },
+                "npm-asset-main": "imagesloaded.js",
+                "npm-asset-directories": {
+                    "test": "test"
+                },
+                "npm-asset-repository": {
+                    "type": "git",
+                    "url": "git://github.com/desandro/imagesloaded.git"
+                },
+                "npm-asset-scripts": {
+                    "test": "echo \"Error: no test specified\" && exit 1"
+                }
+            },
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "David DeSandro"
+                }
+            ],
+            "description": "JavaScript is all like _You images done yet or what?_",
+            "homepage": "https://github.com/desandro/imagesloaded",
+            "keywords": [
+                "dom",
+                "images",
+                "jquery-plugin",
+                "loaded",
+                "ui"
+            ],
+            "time": "2018-01-02T16:56:03+00:00"
+        },
         {
             "name": "npm-asset/jgrowl",
             "version": "1.4.6",
index d64ea5d709114f2bf2a8f37c3df1061b85e1e73b..088da0143c5954f849a4bbf62007956d53e59a16 100644 (file)
@@ -19,10 +19,6 @@ function update_community_content(App $a) {
                $text = '';
        }
 
-       $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
-       $replace = "<img\${1} dst=\"\${2}\"";
-       $text = preg_replace($pattern, $replace, $text);
-
        if (PConfig::get(local_user(), "system", "bandwidth_saver")) {
                $replace = "<br />".L10n::t("[Embedded content - reload page to view]")."<br />";
                $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
index 48df9797de7ba4c5b21abb433c3ab959faa3aa44..4b6d26cb7f4fb9303cf8ff3cee72be1caad1d70a 100644 (file)
@@ -19,9 +19,6 @@ function update_display_content(App $a)
        echo "<section>";
 
        $text = display_content($a, true, $profile_uid);
-       $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
-       $replace = "<img\${1} dst=\"\${2}\"";
-       $text = preg_replace($pattern, $replace, $text);
 
        if (PConfig::get(local_user(), "system", "bandwidth_saver")) {
                $replace = "<br />" . L10n::t("[Embedded content - reload page to view]") . "<br />";
index 962701627a2979d68c30b77e540a197f1f45771d..6c02e4a8fabf98ad212b5e6153f8cabead1f4136 100644 (file)
@@ -25,10 +25,6 @@ function update_network_content(App $a)
                $text = "";
        }
 
-       $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
-       $replace = "<img\${1} dst=\"\${2}\"";
-       $text = preg_replace($pattern, $replace, $text);
-
        if (PConfig::get(local_user(), "system", "bandwidth_saver")) {
                $replace = "<br />" . L10n::t("[Embedded content - reload page to view]") . "<br />";
                $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
index 892e71d782bcc43f437dfd46ca56625f494c1457..7db60e78e077a664eb2a6e328553a3b89f43f43e 100644 (file)
@@ -32,10 +32,6 @@ function update_notes_content(App $a) {
 
        $text = notes_content($a, $profile_uid);
 
-       $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
-       $replace = "<img\${1} dst=\"\${2}\"";
-       $text = preg_replace($pattern, $replace, $text);
-
        if (PConfig::get(local_user(), "system", "bandwidth_saver")) {
                $replace = "<br />".L10n::t("[Embedded content - reload page to view]")."<br />";
                $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
index 1a05130e0a52b562cbd09935eff8359c3f851652..984fd7949cffbe1393d004fa6a7d4ab0a37204f9 100644 (file)
@@ -31,10 +31,6 @@ function update_profile_content(App $a) {
 
        $text = profile_content($a, $profile_uid);
 
-       $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
-       $replace = "<img\${1} dst=\"\${2}\"";
-       $text = preg_replace($pattern, $replace, $text);
-
        if (PConfig::get(local_user(), "system", "bandwidth_saver")) {
                $replace = "<br />".L10n::t("[Embedded content - reload page to view]")."<br />";
                $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
index b5043601ced034b193bed4d0529f7f56774e04c7..88cfe89ee6b41727e872fc6ed61d67ceb3fe731f 100644 (file)
@@ -395,6 +395,47 @@ function NavUpdate() {
        timer = setTimeout(NavUpdate, updateInterval);
 }
 
+function updateConvItems(data) {
+       // add a new thread
+       $('.toplevel_item',data).each(function() {
+               var ident = $(this).attr('id');
+
+               // Add new top-level item.
+               if ($('#' + ident).length == 0 && profile_page == 1) {
+                       $('#' + prev).after($(this));
+
+               // Replace already existing thread.
+               } else {
+                       // Find out if the hidden comments are open, so we can keep it that way
+                       // if a new comment has been posted
+                       var id = $('.hide-comments-total', this).attr('id');
+                       if (typeof id != 'undefined') {
+                               id = id.split('-')[3];
+                               var commentsOpen = $("#collapsed-comments-" + id).is(":visible");
+                       }
+
+                       $('#' + ident).replaceWith($(this));
+
+                       if (typeof id != 'undefined') {
+                               if (commentsOpen) {
+                                       showHideComments(id);
+                               }
+                       }
+               }
+               prev = ident;
+       });
+
+       $('.like-rotator').hide();
+       if (commentBusy) {
+               commentBusy = false;
+               $('body').css('cursor', 'auto');
+       }
+       /* autocomplete @nicknames */
+       $(".comment-edit-form  textarea").editor_autocomplete(baseurl+"/acl");
+       /* autocomplete bbcode */
+       $(".comment-edit-form  textarea").bbco_autocomplete('bbcode');
+}
+
 function liveUpdate(src) {
        if ((src == null) || stopped || !profile_uid) {
                $('.like-rotator').hide(); return;
@@ -418,6 +459,9 @@ function liveUpdate(src) {
        if ($(document).scrollTop() == 0) {
                force_update = true;
        }
+
+       var orgHeight = $("section").height();
+
        var udargs = ((netargs.length) ? '/' + netargs : '');
        var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&force=' + ((force_update) ? 1 : 0) + '&item=' + update_item;
 
@@ -426,52 +470,15 @@ function liveUpdate(src) {
                force_update = false;
                update_item = 0;
 
-               // add a new thread
-               $('.toplevel_item',data).each(function() {
-                       var ident = $(this).attr('id');
-
-                       if ($('#' + ident).length == 0 && profile_page == 1) {
-                               $('img',this).each(function() {
-                                       $(this).attr('src',$(this).attr('dst'));
-                               });
-                               $('#' + prev).after($(this));
-                       } else {
-                               // Find out if the hidden comments are open, so we can keep it that way
-                               // if a new comment has been posted
-                               var id = $('.hide-comments-total', this).attr('id');
-                               if (typeof id != 'undefined') {
-                                       id = id.split('-')[3];
-                                       var commentsOpen = $("#collapsed-comments-" + id).is(":visible");
-                               }
-
-                               $('img',this).each(function() {
-                                       $(this).attr('src',$(this).attr('dst'));
-                               });
-                               $('html').height($('html').height());
-                               $('#' + ident).replaceWith($(this));
+               $('.wall-item-body', data).imagesLoaded(function() {
+                       updateConvItems(data);
 
-                               if (typeof id != 'undefined') {
-                                       if (commentsOpen) {
-                                               showHideComments(id);
-                                       }
-                               }
-                               $('html').height('auto');
-                       }
-                       prev = ident;
+                       // Update the scroll position.
+                       $(window).scrollTop($(window).scrollTop() + $("section").height() - orgHeight);
                });
 
                callAddonHooks("postprocess_liveupdate");
 
-               $('.like-rotator').hide();
-               if (commentBusy) {
-                       commentBusy = false;
-                       $('body').css('cursor', 'auto');
-               }
-               /* autocomplete @nicknames */
-               $(".comment-edit-form  textarea").editor_autocomplete(baseurl+"/acl");
-               /* autocomplete bbcode */
-               $(".comment-edit-form  textarea").bbco_autocomplete('bbcode');
-
        });
 
 }
index b3dfbc1f4e0e0923b789edfd5ace8fc89d5d5e84..aadbfcd8eeb9e944e8d64ea951d514cde77617bb 100644 (file)
@@ -42,6 +42,7 @@
 <script type="text/javascript" src="view/asset/jgrowl/jquery.jgrowl.min.js"></script>
 <script type="text/javascript" src="view/asset/jquery-datetimepicker/build/jquery.datetimepicker.full.min.js"></script>
 <script type="text/javascript" src="view/asset/perfect-scrollbar/js/perfect-scrollbar.jquery.min.js" ></script>
+<script type="text/javascript" src="view/asset/imagesloaded/imagesloaded.pkgd.min.js"></script>
 <script type="text/javascript" src="view/js/acl.js" ></script>
 <script type="text/javascript" src="view/asset/base64/base64.min.js" ></script>
 <script type="text/javascript" src="view/js/addon-hooks.js" ></script>
index f4bcabdae8d276be9dbeffec05c80048f27da684..ef1cd810b0ee37d07b54f2686c474ed186b416bb 100644 (file)
@@ -66,6 +66,7 @@
 <script type="text/javascript" src="view/asset/jgrowl/jquery.jgrowl.min.js"></script>
 <script type="text/javascript" src="view/asset/jquery-datetimepicker/build/jquery.datetimepicker.full.min.js"></script>
 <script type="text/javascript" src="view/asset/perfect-scrollbar/js/perfect-scrollbar.jquery.min.js"></script>
+<script type="text/javascript" src="view/asset/imagesloaded/imagesloaded.pkgd.min.js"></script>
 <script type="text/javascript" src="view/js/acl.js"></script>
 <script type="text/javascript" src="view/asset/base64/base64.min.js"></script>
 <script type="text/javascript" src="view/js/addon-hooks.js" ></script>
index 649ad341f602f811d49dd639684e271af1b9dff2..cf79b24c076e5b3d7b7ff4a07ca9fe11396630c3 100644 (file)
@@ -23,7 +23,7 @@
                </div>
                <div class="wall-item-content">
                        {{if $item.title}}<h2><a href="{{$item.plink.href}}">{{$item.title}}</a></h2>{{/if}}
-                       {{$item.body}}
+                       <div class="wall-item-body">{{$item.body}}</div>
                </div>
        </div>
        <div class="wall-item-bottom">
index 89832403fcfa7ac0d7d844ad6b26fb8e623e562e..79bf1d6b6f028477120551e99cb1f211fad0fc5d 100644 (file)
@@ -60,7 +60,7 @@
                </div>
                <div class="wall-item-content">
                        {{if $item.title}}<h2><a href="{{$item.plink.href}}" class="{{$item.sparkle}} p-name">{{$item.title}}</a></h2>{{/if}}
-                       <span class="e-content {{if !$item.title}}p-name{{/if}}">{{$item.body}}</span>
+                       <span class="wall-item-body e-content {{if !$item.title}}p-name{{/if}}">{{$item.body}}</span>
                </div>
        </div>
        <div class="wall-item-bottom">
index f056b0f7a958f7d65a9f62b35d56f42245967594..c1383ba4346151f092b252ffeff909cb59f09b4f 100644 (file)
@@ -30,7 +30,7 @@
                </div>
                <div class="wall-item-content">
                        {{if $item.title}}<h2><a href="{{$item.plink.href}}">{{$item.title}}</a></h2>{{/if}}
-                       {{$item.body}}
+                       <div class="wall-item-body">{{$item.body}}</div>
                </div>
        </div>
        <div class="wall-item-bottom">
index d1588bde30c2e33bfcbcd51eb5a21b885ecd95fd..6c636d53b6000eb159250888ee5ef3286220ae7c 100644 (file)
@@ -67,7 +67,7 @@
 
                <div itemprop="description" class="wall-item-content">
                        {{if $item.title}}<h2><a href="{{$item.plink.href}}" class="{{$item.sparkle}} p-name">{{$item.title}}</a></h2>{{/if}}
-                       <span class="e-content {{if !$item.title}}p-name{{/if}}">{{$item.body}}</span>
+                       <span class="wall-item-body e-content {{if !$item.title}}p-name{{/if}}">{{$item.body}}</span>
                </div>
        </div>
        <div class="wall-item-bottom">