-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dde2d80
commit d480c20
Showing
3 changed files
with
40 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @description tooltip 功能 | ||
* @author wangfupeng | ||
*/ | ||
|
||
import { Dom7Array } from '../../utils/dom' | ||
import { IS_APPLE } from '../../utils/ua' | ||
|
||
export function addTooltip($button: Dom7Array, title: string, hotkey: string, inGroup = false) { | ||
if (hotkey) { | ||
const fnKey = IS_APPLE ? 'cmd' : 'ctrl' // mac OS 转换为 cmd ,windows 转换为 ctrl | ||
hotkey = hotkey.replace('mod', fnKey) | ||
} | ||
|
||
if (inGroup) { | ||
// in groupButton ,tooltip 只显示 快捷键 | ||
if (hotkey) { | ||
$button.attr('data-tooltip', hotkey) | ||
$button.addClass('w-e-menu-tooltip') | ||
$button.addClass('tooltip-right') // tooltip 显示在右侧 | ||
} | ||
} else { | ||
// 非 in groupButton ,正常实现 tooltip | ||
const tooltip = hotkey ? `${title}\n${hotkey}` : title | ||
$button.attr('data-tooltip', tooltip) | ||
$button.addClass('w-e-menu-tooltip') | ||
} | ||
} |