mootools_MooTools快速编码:扩展缩写

mootools

One of the many great reasons for an official MooTools Forge is that I get to check one place to find numerous MooTools plugins that I've never seen before. One such plugin, Expand Abbreviation, allows the developer to create elements using ZEN-Coding methodology. Instead of coding numerous new Element blocks, Expand Abbreviation generates elements for you based on a string syntax.

正式使用MooTools Forge的众多重要原因之一就是,我可以去一个地方找到许多我从未见过的MooTools插件。 这样的插件Expand Expand允许开发人员使用ZEN-Coding方法创建元素。 无需编写大量新的Element块,Expand Abbreviation会基于字符串语法为您生成元素。

样品用量 (Sample Usage)


window.addEvent('domready', function() {
	// Generating Header
	document.body.expanAbbr( 'div#header>div#logo^text=Containing Logo+div#navigation+div#subnavigation' );

	// the Navigation with some li's and a's
	$('navigation').expanAbbr( 'ul>li*3>a^href=http://www.google.com,text=GOOGLE,target=_blank,title=a navigation link' );

	// the Navigation with some li's and a's
	$('subnavigation').expanAbbr( 'ul>li*5>a^href=http://www.nyt.com,text=NYT,title=a link' );

	// Generating Main Content Body with left and right column
	document.body.expanAbbr( 'div#main>div#content' );
	$('content').expanAbbr( 'div.box*24>h3^text=a little box+p^text=with some content' );
	$('content').expanAbbr( 'br^style=clear:both' );

	// Generating Footer and Sitemap Body
	document.body.expanAbbr( 'div#bottom>div#sitemap^text=The Sitemap+div#footer^text=The Footer' );
});


There's a lot there so lets take one and talk through what it does.

这里有很多东西,所以让我们来谈一谈它的作用。


$('navigation').expanAbbr( 'ul>li*3>a^href=http://www.google.com,text=GOOGLE,target=_blank,title=a navigation link' );


The above code:

上面的代码:

  • Creates a UL element within the "navigation" element.

    在“导航”元素内创建UL元素。
  • Creates 3 list items within the UL

    在UL内创建3个列表项
  • Creates an A element within each link with assigned text and HREF and TARGET attributes.

    在每个链接内使用分配的文本以及HREF和TARGET属性创建一个A元素。

Once the elements are in place, you can modify them as you could any other element. While this plugin likely wont be used by the majority of MooTools developers, it's a great option for those who want create elements quickly and with minimal code.

一旦元素就位,就可以像修改其他任何元素一样对其进行修改。 虽然大多数MooTools开发人员都不会使用此插件,但对于那些想要快速创建元素并使用最少代码的人来说,这是一个不错的选择。

翻译自: https://davidwalsh.name/mootools-expand-abbreviation

mootools

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值