From 06a931c1cb0d37550962bf948fbcaac76ea79c99 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 13 Nov 2018 12:43:46 -0700 Subject: [PATCH] Add readmore.js --- package-lock.json | 11 +++++++++-- package.json | 1 + resources/assets/js/components.js | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 25804cb8..8b02ae80 100644 --- a/package-lock.json +++ b/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", diff --git a/package.json b/package.json index 37244a4a..8cd0b0c3 100644 --- a/package.json +++ b/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", diff --git a/resources/assets/js/components.js b/resources/assets/js/components.js index 4f4ceaf1..20305a85 100644 --- a/resources/assets/js/components.js +++ b/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: 'Read more', + lessLink: 'Hide', + }); + }); +}; + window.InfiniteScroll = require('infinite-scroll'); window.filesize = require('filesize'); import swal from 'sweetalert';