add target _blank
This commit is contained in:
parent
918c55da3e
commit
b6c6fc2486
|
@ -54,7 +54,7 @@ class JsController extends Controller
|
||||||
{
|
{
|
||||||
$user = OC::$server[IUserSession::class]->getUser();
|
$user = OC::$server[IUserSession::class]->getUser();
|
||||||
$topMenuApps = (array) json_decode($this->config->getAppValue('side_menu', 'top-menu-apps', '[]'), true);
|
$topMenuApps = (array) json_decode($this->config->getAppValue('side_menu', 'top-menu-apps', '[]'), true);
|
||||||
$targetBlank = (bool) $this->config->getAppValue('side_menu', 'target-blank', '0');
|
$targetBlankApps = (array) json_decode($this->config->getAppValue('side_menu', 'target-blank-apps', '[]'), true);
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$userTopMenuApps = (array) json_decode($this->config->getUserValue($user->getUid(), 'side_menu', 'top-menu-apps', '[]'), true);
|
$userTopMenuApps = (array) json_decode($this->config->getUserValue($user->getUid(), 'side_menu', 'top-menu-apps', '[]'), true);
|
||||||
|
@ -63,10 +63,11 @@ class JsController extends Controller
|
||||||
$topMenuApps = $userTopMenuApps;
|
$topMenuApps = $userTopMenuApps;
|
||||||
}
|
}
|
||||||
|
|
||||||
$userTargetBlank = (int) $this->config->getUserValue($user->getUid(), 'side_menu', 'target-blank', '-1');
|
$userTargetBlankMode = (int) $this->config->getUserValue($user->getUid(), 'side_menu', 'target-blank-mode', '1');
|
||||||
|
$userTargetBlankApps = (array) json_decode($this->config->getUserValue($user->getUid(), 'side_menu', 'target-blank-apps', '[]'), true);
|
||||||
|
|
||||||
if ($userTargetBlank !== -1) {
|
if ($userTargetBlankMode === 2) {
|
||||||
$targetBlank = (bool) $userTargetBlank;
|
$targetBlankApps = $userTargetBlankApps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ class JsController extends Controller
|
||||||
'always-displayed' => (bool) $this->config->getAppValue('side_menu', 'always-displayed', '0'),
|
'always-displayed' => (bool) $this->config->getAppValue('side_menu', 'always-displayed', '0'),
|
||||||
'big-menu' => (bool) $this->config->getAppValue('side_menu', 'big-menu', '0'),
|
'big-menu' => (bool) $this->config->getAppValue('side_menu', 'big-menu', '0'),
|
||||||
'top-menu-apps' => $topMenuApps,
|
'top-menu-apps' => $topMenuApps,
|
||||||
'target-blank' => $targetBlank,
|
'target-blank-apps' => $targetBlankApps,
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = new TemplateResponse('side_menu', 'js/script', $parameters, 'blank');
|
$response = new TemplateResponse('side_menu', 'js/script', $parameters, 'blank');
|
||||||
|
|
|
@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
<ul class="side-menu-apps-list">
|
<ul class="side-menu-apps-list">
|
||||||
<li v-for="app in apps" v-bind:class="{'side-menu-app': true, 'active': app.active}">
|
<li v-for="app in apps" v-bind:class="{'side-menu-app': true, 'active': app.active}">
|
||||||
<a v-bind:href="app.href" :target="targetBlank ? '_blank' : undefined" v-bind:title="app.name">
|
<a v-bind:href="app.href" :target="targetBlankApps.indexOf(app.id) !== -1 ? '_blank' : undefined" v-bind:title="app.name">
|
||||||
<span class="side-menu-app-icon" v-html="app.icon"></span>
|
<span class="side-menu-app-icon" v-html="app.icon"></span>
|
||||||
<span class="side-menu-app-text" v-html="app.name"></span>
|
<span class="side-menu-app-text" v-html="app.name"></span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -87,6 +87,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.apps.push({
|
this.apps.push({
|
||||||
|
id: dataId,
|
||||||
href: href,
|
href: href,
|
||||||
name: trim(element.querySelector('span').innerHTML),
|
name: trim(element.querySelector('span').innerHTML),
|
||||||
icon: svg,
|
icon: svg,
|
||||||
|
@ -120,7 +121,7 @@ export default {
|
||||||
this.retrieveApps()
|
this.retrieveApps()
|
||||||
this.retrieveLogo()
|
this.retrieveLogo()
|
||||||
this.forceLightIcon = document.querySelector('#side-menu-container').getAttribute('data-forcelighticon') == 1;
|
this.forceLightIcon = document.querySelector('#side-menu-container').getAttribute('data-forcelighticon') == 1;
|
||||||
this.targetBlank = document.querySelector('#side-menu-container').getAttribute('data-targetblank') == 1;
|
this.targetBlankApps = document.querySelector('#side-menu-container').getAttribute('data-targetblankapps').split(',');
|
||||||
|
|
||||||
const menu = document.querySelector('#appmenu')
|
const menu = document.querySelector('#appmenu')
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
<ul class="side-menu-apps-list">
|
<ul class="side-menu-apps-list">
|
||||||
<li v-bind:class="{'side-menu-app': true, 'active': activeApp === appId}" v-for="(app, appId) in category.apps">
|
<li v-bind:class="{'side-menu-app': true, 'active': activeApp === appId}" v-for="(app, appId) in category.apps">
|
||||||
<a v-bind:href="app.href" :target="targetBlank ? '_blank' : undefined" v-bind:title="app.name">
|
<a v-bind:href="app.href" :target="targetBlankApps.indexOf(appId) !== -1 ? '_blank' : undefined" v-bind:title="app.name">
|
||||||
<img class="side-menu-app-icon" v-bind:src="app.icon"></span>
|
<img class="side-menu-app-icon" v-bind:src="app.icon"></span>
|
||||||
<span class="side-menu-app-text" v-html="app.name"></span>
|
<span class="side-menu-app-text" v-html="app.name"></span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -80,7 +80,7 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.targetBlank = document.querySelector('#side-menu-container').getAttribute('data-targetblank') == 1;
|
this.targetBlankApps = document.querySelector('#side-menu-container').getAttribute('data-targetblankapps').split(',');
|
||||||
|
|
||||||
this.retrieveApps()
|
this.retrieveApps()
|
||||||
this.retrieveActiveApp()
|
this.retrieveActiveApp()
|
||||||
|
|
|
@ -38,6 +38,10 @@ var updateTopMenu = function() {
|
||||||
appShown.push(app)
|
appShown.push(app)
|
||||||
navigationApps.append(app.outerHTML)
|
navigationApps.append(app.outerHTML)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (targetBlankApps.indexOf(dataId) !== -1) {
|
||||||
|
jQuery(app).children('a').attr('target', '_blank');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var rightHeaderWidth = jQuery('.header-right').outerWidth()
|
var rightHeaderWidth = jQuery('.header-right').outerWidth()
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
sideMenuContainer.attr('data-forcelighticon', '1')
|
sideMenuContainer.attr('data-forcelighticon', '1')
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($_['target-blank']): ?>
|
sideMenuContainer.attr('data-targetblankapps', '<?php p(implode(',', $_['target-blank-apps'])) ?>')
|
||||||
sideMenuContainer.attr('data-targetblank', '1')
|
|
||||||
<?php endif; ?>
|
var targetBlankApps = <?php echo json_encode($_['target-blank-apps']) ?>;
|
||||||
|
|
||||||
body.on('side-menu.apps', function(e, apps) {
|
body.on('side-menu.apps', function(e, apps) {
|
||||||
<?php if ($_['hide-when-no-apps']): ?>
|
<?php if ($_['hide-when-no-apps']): ?>
|
||||||
|
|
Loading…
Reference in a new issue