Browse Source

Add readmore.js

Daniel Supernault 6 years ago
parent
commit
06a931c1cb
3 changed files with 26 additions and 2 deletions
  1. 9 2
      package-lock.json
  2. 1 0
      package.json
  3. 16 0
      resources/assets/js/components.js

+ 9 - 2
package-lock.json

@@ -5482,8 +5482,7 @@
         "jquery": {
             "version": "3.3.1",
             "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
-            "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==",
-            "dev": true
+            "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg=="
         },
         "js-base64": {
             "version": "2.4.9",
@@ -9431,6 +9430,14 @@
                 "readable-stream": "^2.0.2"
             }
         },
+        "readmore-js": {
+            "version": "2.2.1",
+            "resolved": "https://registry.npmjs.org/readmore-js/-/readmore-js-2.2.1.tgz",
+            "integrity": "sha512-hbPP0nQpYYkAywCEZ8ozHivvhWyHic37KJ2IXrHES4qzjp0+nmw8R33MeyMAtXBZfXX4Es8cpd5JBVf9qj47+Q==",
+            "requires": {
+                "jquery": ">2.1.4"
+            }
+        },
         "recast": {
             "version": "0.11.23",
             "resolved": "https://registry.npmjs.org/recast/-/recast-0.11.23.tgz",

+ 1 - 0
package.json

@@ -25,6 +25,7 @@
         "infinite-scroll": "^3.0.4",
         "laravel-echo": "^1.4.0",
         "pusher-js": "^4.2.2",
+        "readmore-js": "^2.2.1",
         "socket.io-client": "^2.1.1",
         "sweetalert": "^2.1.0",
         "twitter-text": "^2.0.5",

+ 16 - 0
resources/assets/js/components.js

@@ -2,6 +2,22 @@ window.Vue = require('vue');
 import BootstrapVue from 'bootstrap-vue'
 Vue.use(BootstrapVue);
 
+pixelfed.readmore = () => {
+  $(document).find('.read-more').each(function(k,v) {
+      let el = $(this);
+      let attr = el.attr('data-readmore');
+      if(typeof attr !== typeof undefined && attr !== false) {
+        return;
+      }
+      el.readmore({
+        collapsedHeight: 44,
+        heightMargin: 20,
+        moreLink: '<a href="#" class="font-weight-bold small">Read more</a>',
+        lessLink: '<a href="#" class="font-weight-bold small">Hide</a>',
+      });
+  });
+};
+
 window.InfiniteScroll = require('infinite-scroll');
 window.filesize = require('filesize');
 import swal from 'sweetalert';