- Fix: Oembed not rendered in richtext.

- Enh: Smarter show more logic - Only cut text if it overlaps the max height by a specific span.
This commit is contained in:
buddh4 2017-02-20 13:31:32 +01:00
parent 50b3e06663
commit 0d50f3f69d
4 changed files with 17 additions and 4 deletions

View File

@ -37,6 +37,9 @@ HumHub Change Log
- Enh: Enhanced ContentContainer Module enable/disable
- Enh: Added client.reload for pjax and non pjax page reloads
- Enh: Added ContentContainerAsset to AppAsset
- Enh: Added editModal for editing wallentries within a modal instead of inline
- Fix: Oembed not rendered in richtext.
- Enh: Smarter show more logic - Only cut text if it overlaps the max height by a specific span.
1.2.0-beta.1 (February 08, 2017)
--------------------------------

View File

@ -112,7 +112,7 @@ class UrlOembed extends \yii\db\ActiveRecord
try {
$data = \yii\helpers\Json::decode($jsonOut);
if (isset($data['type']) && ($data['type'] === "video" || $data['type'] === 'rich' || $data['type'] === 'photo')) {
$html = "<div class='oembed_snippet' data-url='" . \yii\helpers\Html::encode($url) . "'>" . $data['html'] . "</div>";
$html = "<div data-guid='".uniqid('oembed-')."' data-richtext-feature class='oembed_snippet' data-url='" . \yii\helpers\Html::encode($url) . "'>" . $data['html'] . "</div>";
}
} catch (\yii\base\InvalidParamException $ex) {
Yii::warning($ex->getMessage());

View File

@ -121,9 +121,16 @@ humhub.module('ui.additions', function (module, require, $) {
// Export all richtext features
var features = {};
$this.find('[data-richtext-feature]').each(function () {
$this.find('[data-richtext-feature], .oembed_snippet').each(function () {
var $this = $(this);
var featureKey = $this.data('guid') || '@-'+$this.attr('id');
// old oembeds
if($this.is('.oembed_snippted') && !$this.data('guid')) {
featureKey = '@-oembed-'+$this.data('url');
}
features[featureKey] = $this.clone();
// We add a space to make sure our placeholder is not appended to any link or something.
$this.replaceWith(' '+featureKey);

View File

@ -1,10 +1,12 @@
humhub.module('ui.showMore', function (module, require, $) {
var additions = require('ui.additions');
var DEFAULT_COLLAPSE_AT = 310;
var CollapseContent = function (node, options) {
this.options = options || {};
this.$ = node instanceof $ ? node : $(node);
this.collapseAt = this.$.data('collapse-at') || 310;
this.collapseAt = this.$.data('collapse-at') || DEFAULT_COLLAPSE_AT;
this.options.readMoreText = this.$.data('read-more-text') || module.text('readMore');
this.options.readLessText = this.$.data('read-less-text') || module.text('readLess');
this.init();
@ -14,9 +16,10 @@ humhub.module('ui.showMore', function (module, require, $) {
var that = this;
var height = this.$.outerHeight();
this.$collapseButton = this.$.siblings('.showMore');
var diff = height - this.collapseAt;
// If height expands the max height we init the collapse post logic
if (height > this.collapseAt) {
if (height > this.collapseAt && diff > 70) {
if (!this.$collapseButton.length) {
this.$collapseButton = $(module.templates.showMore);
that.$.after(this.$collapseButton);