feat(core): dropdown menu item default event

This commit is contained in:
OldHawk
2018-05-16 16:43:44 +08:00
parent 44e664ecac
commit b95cc5d7f0
4 changed files with 15 additions and 6 deletions

View File

@@ -47,11 +47,17 @@
});
//set menu bar opened when hover
$('div.navbar-mt ul.nav li.dropdown').hover(function () {
$('div.navbar-mt ul.nav li.dropdown').hover(function (evt) {
if (!$(this).hasClass('open')) {
$(this).find('.dropdown-toggle', this).trigger('click');
$(this).bind('click', function (e) {
var sta = $(this).find('.dropdown-toggle', this).attr('alt');
if (sta)
$state.go(sta);
});
}
}, function () {
}, function (evt) {
$(this).unbind('click');
if ($(this).hasClass('open')) {
$(this).find('.dropdown-toggle', this).trigger('click');
}

View File

@@ -61,7 +61,8 @@
target: options.target || undefined,
divider: options.divider || false,
faClass: options.faClass || null,
faIcon: options.faIcon || null
faIcon: options.faIcon || null,
linkState: options.linkState || undefined
});
// Add submenu items
@@ -96,7 +97,8 @@
target: options.target || undefined,
divider: options.divider || false,
faClass: options.faClass || null,
faIcon: options.faIcon || null
faIcon: options.faIcon || null,
linkState: options.linkState || undefined
});
});

View File

@@ -15,7 +15,7 @@
<li ng-repeat="item in vm.menu.items | orderBy: 'position'" ng-if="item.shouldRender(vm.authentication.user);" ng-switch="item.type"
ng-class="{ dropdown: item.type === 'dropdown' }" ui-sref-active="active" class="{{item.class}}"
uib-dropdown="item.type === 'dropdown'">
<a ng-switch-when="dropdown" class="dropdown-toggle" uib-dropdown-toggle role="button"><span
<a ng-switch-when="dropdown" class="dropdown-toggle" uib-dropdown-toggle role="button" alt="{{item.linkState}}"><span
menu-title="{{item.title}}">{{::item.title}}</span>&nbsp;<span class="caret"></span></a>
<ul ng-switch-when="dropdown" class="dropdown-menu">
<li ui-sref-active="active" ng-repeat="subitem in item.items | orderBy: 'position'"
@@ -48,7 +48,7 @@
{{'TABLE_FIELDS.LEECHED' | translate}}: {{vm.authentication.user.leeched}}</span>
</li>
<li class="dropdown" uib-dropdown>
<a class="dropdown-toggle user-header-dropdown-toggle" uib-dropdown-toggle role="button">
<a class="dropdown-toggle user-header-dropdown-toggle" uib-dropdown-toggle role="button" alt="status.account">
<img ng-src="{{vm.authentication.user.profileImageURL}}" alt="{{vm.authentication.user.displayName}}"
class="header-profile-image"/>
<span class="sm-hide" ng-bind="vm.authentication.user.displayName"></span> <b class="caret"></b>

View File

@@ -13,6 +13,7 @@
menuService.addMenuItem('topbar', {
title: 'MENU_TORRENTS',
state: 'torrents',
linkState: 'torrents.aggregate',
type: 'dropdown',
roles: ['*'],
position: 0