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开发人员都不会使用此插件,但对于那些想要快速创建元素并使用最少代码的人来说,这是一个不错的选择。
mootools