- Enh: added js module 'ui.view' for view state and utils - Changed 'ui.state.getState' to 'ui.view.getState'

- Enh: added view helper as getHeight/Width and isSmall/Medium/Normal (width) to 'ui.view' js module
- Fix: removed popover image preview from mobile
- Fix: removed target-densitydpi not supported warning
This commit is contained in:
buddh4 2017-03-15 20:10:31 +01:00
parent 9746d374ed
commit 8284dcc129
6 changed files with 76 additions and 15 deletions

View File

@ -45,6 +45,7 @@ class CoreApiAsset extends AssetBundle
'js/humhub/humhub.core.js',
'js/humhub/humhub.util.js',
'js/humhub/humhub.log.js',
'js/humhub/humhub.ui.view.js',
'js/humhub/humhub.ui.additions.js',
'js/humhub/humhub.ui.showMore.js',
'js/humhub/humhub.ui.form.elements.js',

View File

@ -221,7 +221,7 @@ class Controller extends \yii\web\Controller
public function setJsViewStatus()
{
$modluleId = (Yii::$app->controller->module) ? Yii::$app->controller->module->id : '';
$this->view->registerJs('humhub.modules.ui.status.setState("' . $modluleId . '", "' . Yii::$app->controller->id . '", "' . Yii::$app->controller->action->id . '");', \yii\web\View::POS_BEGIN);
$this->view->registerJs('humhub.modules.ui.view.setState("' . $modluleId . '", "' . Yii::$app->controller->id . '", "' . Yii::$app->controller->action->id . '");', \yii\web\View::POS_BEGIN);
if(Yii::$app->request->isPjax) {
\humhub\widgets\TopMenu::setViewState();

View File

@ -12,6 +12,8 @@ humhub.module('file', function (module, require, $) {
var string = util.string;
var action = require('action');
var event = require('event');
var view = require('ui.view');
var Upload = function (node, options) {
Widget.call(this, node, options);
@ -330,16 +332,18 @@ humhub.module('file', function (module, require, $) {
if (file.thumbnailUrl && !this.options.preventPopover) {
// Preload image
new Image().src = file.thumbnailUrl;
$file.find('.file-preview-content').popover({
html: true,
trigger: 'hover',
animation: 'fade',
delay: 100,
placement: this.options.popoverPosition || 'right',
content: function () {
return string.template(Preview.template.popover, file);
}
});
if(!view.isSmall()) {
$file.find('.file-preview-content').popover({
html: true,
trigger: 'hover',
animation: 'fade',
delay: 100,
placement: this.options.popoverPosition || 'right',
content: function () {
return string.template(Preview.template.popover, file);
}
});
}
};
var that = this;

View File

@ -10,7 +10,7 @@ humhub.module('notification', function (module, require, $) {
var Widget = require('ui.widget').Widget;
var event = require('event');
var client = require('client');
var status = require('ui.status');
var view = require('ui.view');
var user = require('user');
module.initOnPjaxLoad = true;
@ -207,9 +207,9 @@ humhub.module('notification', function (module, require, $) {
var updateTitle = function ($count) {
if ($count) {
document.title = '(' + $count + ') ' + status.getState().title;
document.title = '(' + $count + ') ' + view.getState().title;
} else if ($count === false) {
document.title = status.getState().title;
document.title = view.getState().title;
}
};

View File

@ -10,7 +10,7 @@
<head>
<title><?php echo $this->pageTitle; ?></title>
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<?php $this->head() ?>
<?= $this->render('head'); ?>
</head>

View File

@ -0,0 +1,56 @@
humhub.module('ui.view', function (module, require, $) {
var title;
var state = {};
var isSmall = function () {
return module.getWidth() <= 767;
};
var isMedium = function () {
return module.getWidth() > 767 && module.getWidth() <= 991;
};
var isNormal = function () {
return module.getWidth() >= 991;
};
var setState = function (moduleId, controlerId, action) {
state = {
title: title || document.title,
moduleId: moduleId,
controllerId: controlerId,
action: action
};
};
var getHeight = function() {
return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
};
var getWidth = function() {
return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
};
module.initOnPjaxLoad = true;
var init = function ($pjax) {
title = document.title;
module.log.debug('Current view state', state);
};
module.export({
init: init,
isSmall: isSmall,
isMedium: isMedium,
isNormal: isNormal,
getHeight: getHeight,
getWidth: getWidth,
// This function is called by controller itself
setState: setState,
getState: function () {
return $.extend({}, state);
},
getTitle: function () {
return state.title;
}
});
});