Chng: Use of BlueimpGalleryAsset npm asset instead of static asset file

Enh: Add gallery view of richtext images
This commit is contained in:
buddh4 2019-12-06 13:48:51 +01:00
parent 75457b90b2
commit bb99b12a38
6 changed files with 75 additions and 5 deletions

View File

@ -18,6 +18,7 @@
"npm-asset/jquery-autosize": "1.*",
"npm-asset/bluebird": "^3.3.5",
"npm-asset/blueimp-file-upload": "9.24.*",
"npm-asset/blueimp-gallery": "2.36.0",
"npm-asset/bootstrap-markdown": "2.10.*",
"npm-asset/clipboard-polyfill": "*",
"npm-asset/font-awesome": "^4.7.0",

18
composer.lock generated
View File

@ -1,10 +1,10 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6b057901539281a2504ccd6b2f628578",
"content-hash": "5b2fc2e65860abe0c92942c2be8f0617",
"packages": [
{
"name": "bower-asset/bootstrap",
@ -2020,6 +2020,20 @@
"MIT"
]
},
{
"name": "npm-asset/blueimp-gallery",
"version": "2.36.0",
"dist": {
"type": "tar",
"url": "https://registry.npmjs.org/blueimp-gallery/-/blueimp-gallery-2.36.0.tgz",
"reference": null,
"shasum": null
},
"type": "npm-asset",
"license": [
"MIT"
]
},
{
"name": "npm-asset/blueimp-load-image",
"version": "2.12.2",

View File

@ -37,7 +37,6 @@ class AppAsset extends AssetBundle
'css/temp.css',
'css/bootstrap-wysihtml5.css',
'css/flatelements.css',
'css/blueimp-gallery.min.css'
];
/**
@ -58,6 +57,7 @@ class AppAsset extends AssetBundle
'humhub\assets\JqueryColorAsset',
'humhub\assets\FontAwesomeAsset',
'humhub\assets\BlueimpFileUploadAsset',
'humhub\assets\BlueimpGalleryAsset',
'humhub\assets\JqueryHighlightAsset',
'humhub\assets\JqueryCookieAsset',
'humhub\assets\JqueryAutosizeAsset',
@ -91,7 +91,6 @@ class AppAsset extends AssetBundle
* @inheritdoc
*/
public $js = [
'js/blueimp-gallery.min.js',
'js/jquery.highlight.min.js',
'js/desktop-notify-min.js',
'js/desktop-notify-config.js',

View File

@ -0,0 +1,44 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\assets;
use yii\web\AssetBundle;
/**
* jQery Blueimp File Upload
*
* @author luke
*/
class BlueimpGalleryAsset extends AssetBundle
{
/**
* @inheritdoc
*/
public $sourcePath = '@npm/blueimp-gallery';
/**
* @inheritdoc
*/
public $js = [
'js/blueimp-gallery.min.js',
];
public $css = [
'css/blueimp-gallery.min.css',
];
/**
* @inheritdoc
*/
public $depends = [
'humhub\assets\JqueryWidgetAsset',
];
}

View File

@ -27,6 +27,8 @@ HumHub Change Log (DEVELOP)
- Enh: Added `data-ui-addition` way of defining ui additions
- Enh #3771: Added `data-ui-addition="acknowledgeForm"` in order to prevent page changes without save/confirmation
- Enh #3771: Added `humhub\modules\ui\form\widgets\ActiveForm:acknowledge` flag
- Chng: Use of `BlueimpGalleryAsset` npm asset instead of static asset file
- Enh: Add gallery view of richtext images
1.4
---

View File

@ -7,12 +7,22 @@ humhub.module('ui.gallery', function (module, require, $) {
var init = function () {
$(document).on('click.humhub:ui:gallery', '[data-ui-gallery]', function (evt) {
var $this = $(this);
if($this.is('img') && $this.closest('a').length) {
return;
}
evt.preventDefault();
evt.stopPropagation();
var $this = $(this);
var gallery = $this.data('ui-gallery');
var $links = (gallery) ? $('[data-ui-gallery="' + gallery + '"]') : $this.parent().find('[data-ui-gallery]');
var options = {index: $this[0], event: evt.originalEvent};
if($this.is('img')) {
options['urlProperty'] = 'src';
}
blueimp.Gallery($links.get(), options);
});
};