dijit之Tooltip

本文详细介绍了如何使用 Dojo 框架中的 Tooltip 组件,包括配置主题样式表、加载 JavaScript 类、设置基本属性和使用方法等内容。通过编程式及声明式示例展示了 Tooltip 的灵活运用。

The setup for using dijit/Tooltip is the same as using any Dijit widget: add the desired theme stylesheet to the page, add the name of the theme as a CSS class to the body node, and require the widget's JavaScript class:

<script>
    // Load the Tooltip widget class
    require(["dijit/Tooltip",  "dojo/parser", "dojo/domReady!"], function(Tooltip, parser){
        parser.parse();
    });
</script>

With the theme and widget class loaded, a basic example of programmatic dijit/Tooltip usage would look like:

// Create a new Tooltip
var tip = new Tooltip({
    // Label - the HTML or text to be placed within the Tooltip
    label: '&lt;div class="myTipType"&gt;This is the content of my Tooltip!&lt;/div&gt;',
    // Delay before showing the Tooltip (in milliseconds)
    showDelay: 250,
    // The nodes to attach the Tooltip to
    // Can be an array of strings or domNodes
    connectId: ["myElement1","myElement2"]
});

Important dijit/Tooltip properties include:

  • connectId - An array of IDs or DOM nodes that the Tooltip should be connected to
  • label - The HTML or text content to be placed within the Tooltip
  • showDelay - The show delay of the Tooltip

Notable dijit/Tooltip methods include:

  • addTarget - Adds a Tooltip target if not already connected
  • close - Closes a Tooltip instance (hides its visibility)
  • open - Opens a Tooltip instance (makes the Tooltip visible)
  • removeTarget - Removes a node from the Tooltip target list
  • set - Allows for changing of properties, most notably Tooltip content (myTip.set("label","New content!"))

The dijit/Tooltip object also hosts a configurable defaultPosition array which contains the desired order which a Tooltip instance should try to display:

Tooltip.defaultPosition = ["above", "below", "after-centered", "before-centered"];

声明式Tooltip例1:

<!doctype html>
<html lang="en" dir="ltr">
	<head>
	    <title>Declarative Tooltip</title>
		<link rel="stylesheet" href="dijit/themes/claro/claro.css" />
		<style type="text/css">
			body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
			.div1Style {
				width : 300px;
				height : 600px;
				margin : 200px;
			}
			.div2Style {
				margin-top : 50px;
			}
			
		</style>
				<script src="dojo/dojo.js" data-dojo-config="async: true, parseOnLoad:true"></script>
		<script>
			require(["dijit/Tooltip",  "dojo/parser", "dojo/domReady!"], function(Tooltip, parser){
				parser.parse();
								
			});
		</script>
	</head>
	<body class="claro">
		<div class="div1Style">
			<div class="div2Style">
				<button id="TooltipButton3" οnmοuseοver="dijit.Tooltip.defaultPosition=['after','before']">Tooltip After</button><br/>
				<div class="dijitHidden"><span data-dojo-type="dijit/Tooltip" data-dojo-props="connectId:'TooltipButton3'">
					I am <strong>after</strong> the button</span>
				</div>
			</div>
			
			<div class="div2Style">
				<button id="TooltipButton" οnmοuseοver="dijit.Tooltip.defaultPosition=['above', 'below']">Tooltip Above</button><br/>
				<div class="dijitHidden"><span data-dojo-type="dijit/Tooltip" data-dojo-props="connectId:'TooltipButton'">
					I am <strong>above</strong> the button</span>
				</div>
			</div>
				
				
			<div class="div2Style">
				<button id="TooltipButton2" οnmοuseοver="dijit.Tooltip.defaultPosition=['below','above']">Tooltip Below</button><br/>
				<div class="dijitHidden"><span data-dojo-type="dijit/Tooltip" data-dojo-props="connectId:'TooltipButton2'">
					I am <strong>below</strong> the button</span>
				</div>
			</div>

			<div class="div2Style">
				<button id="TooltipButton4" οnmοuseοver="dijit.Tooltip.defaultPosition=['before','after']">Tooltip Before</button><br/>
				<div class="dijitHidden"><span data-dojo-type="dijit/Tooltip" data-dojo-props="connectId:'TooltipButton4'">
					I am <strong>before</strong> the button</span>
				</div>
			</div>
		</div>
	</body>
</html>


声明式Tooltip例2:


<!doctype html>
<html lang="en" dir="ltr">
    <head>
        <title>Decalrative Tooltip </title>
        <link rel="stylesheet" href="dijit/themes/claro/claro.css" />
        <style type="text/css">
            body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
            
            
        </style>
                <script src="dojo/dojo.js" data-dojo-config="async: true, parseOnLoad:true"></script>
        <script>
            require(["dijit/Tooltip",  "dojo/parser", "dojo/domReady!"], function(Tooltip, parser){
                parser.parse();
                /*new Tooltip({
                    connectId: ["nameTip"],
                    label: "<img src='rod-stewart.jpg' alt='Rod Stewart' width='300' height='404' />"
                });
                // Add Tooltip of North London
                new Tooltip({
                    connectId: ["londonTip"],
                    label: "<img src='emirates-stadium.jpg' alt='The Emirates in London' width='400' height='267' />"
                });
                //Add Tooltip of record
                new Tooltip({
                    connectId: ["recordsTip"],
                    label: "<img src='every-picture.jpg' alt='Every Picture Tells a Story' width='200' height='197' />"
                });
                // Add custom Tooltip
                var myTip = new Tooltip({
                    connectId: ["hoverLink"],
                    label: "Don't I look funky?",
                    "class": "customTip"
                });    */            
            });
        </script>
    </head>
    <body class="claro">
        <ul>
            <li><a href="http://www.imdb.com/title/tt0112573/" id="movieBraveheart">Braveheart</a></li>
            <li><a href="http://www.imdb.com/title/tt0237534/" id="movieBrotherhood">Brotherhood of the Wolf</a></li>
            <li><a href="http://www.imdb.com/title/tt0245844/" id="movieCristo">The Count of Monte Cristo</a></li>
        </ul>
        <div class="dijitHidden">
            <div data-dojo-type="dijit/Tooltip" data-dojo-props="connectId:'movieBraveheart'">
                <img style="width:100px; height:133px; display:block; float:left; margin-right:10px;" src="image/braveheart.jpg" />
                <p style="width:400px;"><strong>Braveheart</strong><br />Braveheart is the partly historical, partly mythological, story of William Wallace, a Scottish common man who fights for his country's freedom from English rule around the end of the 13th century...</p>
                <br style="clear:both;">
            </div>
        </div>
        <div class="dijitHidden">
            <div data-dojo-type="dijit/Tooltip" data-dojo-props="connectId:'movieBrotherhood'">
                <img style="width:100px; height:133px; display:block; float:left; margin-right:10px;" src="image/brotherhood.jpg" />
                <p style="width:400px;"><strong>Brotherhood of the Wolf</strong><br />In 1765 something was stalking the mountains of central France. A 'beast' that pounced on humans and animals with terrible ferocity...</p>
                <br style="clear:both;">
            </div>
        </div>
        <div class="dijitHidden">
            <div data-dojo-type="dijit/Tooltip" data-dojo-props="connectId:'movieCristo'">
                <img style="width:100px; height:133px; display:block; float:left; margin-right:10px;" src="image/count.jpg" />
                <p style="width:400px;"><strong>The Count of Monte Cristo</strong><br />'The Count of Monte Cristo' is a remake of the Alexander Dumas tale by the same name. Dantes, a sailor who is falsely accused of treason by his best friend Fernand, who wants Dantes' girlfriend Mercedes for himself...</p>
                <br style="clear:both;">
            </div>
        </div>
    </body>
</html>




编程式Tooltip例子:

<!doctype html>
<html lang="en" dir="ltr">
    <head>
        <title>Programmatic Tooltip </title>
        <link rel="stylesheet" href="dijit/themes/claro/claro.css" />
        <style type="text/css">
            body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
            .div1Style {
                width : 300px;
                height : 600px;
                margin : 200px;
            }
            .div2Style {
                margin-top : 50px;
            }
            
        </style>
                <script src="dojo/dojo.js" data-dojo-config="async: true, parseOnLoad:true"></script>
        <script>
            require(["dijit/Tooltip",  "dojo/parser", "dojo/domReady!"], function(Tooltip, parser){
                parser.parse();
                new Tooltip({
                    connectId: ["nameTip"],
                    label: "<img src='image/braveheart.jpg' alt='Rod Stewart' width='50px' height='50px' />"
                });
                // Add Tooltip of North London
                new Tooltip({
                    connectId: ["londonTip"],
                    label: "<img src='image/braveheart.jpg' alt='The Emirates in London' width='50px' height='50px' />"
                });
                //Add Tooltip of record
                new Tooltip({
                    connectId: ["recordsTip"],
                    label: "<img src='image/braveheart.jpg' alt='Every Picture Tells a Story' width='50px' height='50px' />"
                });
                // Add custom Tooltip
                var myTip = new Tooltip({
                    connectId: ["hoverLink"],
                    label: "Don't I look funky?",
                    "class": "customTip"
                });            
            });
        </script>
    </head>
    <body class="claro">
        <ul>
            <li><a href="http://www.imdb.com/title/tt0112573/" id="nameTip">Name</a></li>
            <li><a href="http://www.imdb.com/title/tt0237534/" id="londonTip">London</a></li>
            <li><a href="http://www.imdb.com/title/tt0245844/" id="recordsTip">Record</a></li>
            <li><a href="http://www.imdb.com/title/tt0245844/" id="hoverLink">hoverLink</a></li>
        </ul>
        
    </body>
</html>




dnSpy是目前业界广泛使用的一款.NET程序的反编译工具,支持32位和64位系统环境。它允许用户查看和编辑.NET汇编和反编译代码,以及调试.NET程序。该工具通常用于程序开发者在维护和调试过程中分析程序代码,尤其在源代码丢失或者无法获取的情况下,dnSpy能提供很大的帮助。 V6.1.8版本的dnSpy是在此系列软件更新迭代中的一个具体版本号,代表着该软件所具备的功能与性能已经达到了一个相对稳定的水平,对于处理.NET程序具有较高的可用性和稳定性。两个版本,即32位的dnSpy-net-win32和64位的dnSpy-net-win64,确保了不同操作系统架构的用户都能使用dnSpy进行软件分析。 32位的系统架构相较于64位,由于其地址空间的限制,只能支持最多4GB的内存空间使用,这在处理大型项目时可能会出现不足。而64位的系统能够支持更大的内存空间,使得在处理大型项目时更为方便。随着计算机硬件的发展,64位系统已经成为了主流,因此64位的dnSpy也更加受开发者欢迎。 压缩包文件名“dnSpy-net-win64.7z”和“dnSpy-net-win32.7z”中的“.7z”表示该压缩包采用了7-Zip压缩格式,它是一种开源的文件压缩软件,以其高压缩比著称。在实际使用dnSpy时,用户需要下载对应架构的压缩包进行解压安装,以确保软件能够正确运行在用户的操作系统上。 dnSpy工具V6.1.8版本的发布,对于.NET程序员而言,无论是32位系统还是64位系统用户,都是一个提升工作效率的好工具。用户可以根据自己计算机的操作系统架构,选择合适的版本进行下载使用。而对于希望进行深度分析.NET程序的开发者来说,这个工具更是不可或缺的利器。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值