博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mootools_PHP / MooTools 1.2手风琴助手
阅读量:2516 次
发布时间:2019-05-11

本文共 5171 字,大约阅读时间需要 17 分钟。

mootools

The MooTools Accordion plugin seems to be the plugin that people seem to have the most problems with. It's an awesome plugin, so I can see why so many people want to use it, but I think that may be part of the problem. I think people see and want it without sufficient knowledge of MooTools or JavaScript in general. That's why I've created a PHP Accordion class to help make the development of accordions easier and faster.

MooTools Accordion插件似乎是人们似乎遇到最多问题的插件。 这是一个很棒的插件,所以我可以看到为什么这么多人想要使用它,但是我认为这可能是问题的一部分。 我认为人们通常在没有足够的MooTools或JavaScript知识的情况下看到并想要它。 这就是为什么我创建一个PHP手风琴类来帮助使手风琴的开发变得更加轻松和快捷的原因。

PHP类 (The PHP Class)

class accordion{	var $toggler_class;	var $item_class;	var $items;	var $open;		function accordion($toggler_class = 'toggler',$item_class = 'item')	{		$this->items = array();		$this->toggler_class = $toggler_class;		$this->item_class = $item_class;		$this->open = 0;	}		function add_item($toggler_content = '',$item_content = '',$open = 0)	{		$this->items[] = array('toggler'=>$toggler_content,'item'=>$item_content,'open'=>(int)$open);	}		function build()	{		foreach($this->items as $index=>$item)		{			$return.= '   
'.$item['toggler'].'
'.$item['item'].'
'; if($item['open']) { $this->open = $index; } } return $return; } function output() { echo $this->build(); } function output_js($options = '') { return 'window.addEvent(\'domready\', function () { var accordion = new Accordion($$(\'.'.$this->toggler_class.'\'),$$(\'.'.$this->item_class.'\'), { display:'.$this->open.' '.($options ? ', '.$options : '').' }); });'; } }

Check out the usage for comments about the class.

查看用法以获取有关该类的注释。

PHP用法 (The PHP Usage)

$acc = new accordion('toggler','item');$acc->add_item('The Beatles','

The Beatles were a pop and rock group from Liverpool, England. They are one of the most commercially successful and critically acclaimed bands in the history of popular music. The band\'s principal members were John Lennon, Paul McCartney, George Harrison, and Ringo Starr.

The Beatles led the mid-1960s musical "British Invasion" into the United States. Although their initial musical style was rooted in 1950s rock and roll and homegrown skiffle, the group explored genres ranging from Tin Pan Alley to psychedelic rock. Their clothes, styles, and statements made them trend-setters, while their growing social awareness saw their influence extend into the social and cultural revolutions of the 1960s.

Click here to learn more about The Beatles.

');$acc->add_item('Rod Stewart','

Roderick "Rod" David Stewart, CBE (born January 10, 1945), is a singer and songwriter born and raised in London, England, with Scottish and English parentage. He currently resides in Epping. With a distinctive, raspy voice, Stewart came to prominence in the late 1960s and early \'70s with The Jeff Beck Group and then The Faces and began a solo career in 1969, with his debut album An Old Raincoat Won\'t Ever Let You Down.

With his career in its fifth decade, Stewart has achieved numerous hit singles worldwide, most notably in the UK, where he has garnered six consecutive number one albums and his tally of 62 hit singles include 24 that reached the top 10, six of which gained the number one position. It has been estimated that Stewart\'s album and single sales total more than 250 million, easily earning him a place on the list of best-selling music artists.

Click here to learn more about Rod Stewart.

', 1);$acc->add_item('Oasis','

Oasis are an English rock band that formed in Manchester in 1991. The group was formed by Liam Gallagher (lead vocals), Paul Arthurs (guitar), Paul McGuigan (bass) and Tony McCarroll (drums), who were soon joined by Liam\'s older brother Noel Gallagher (lead guitar, vocals). Oasis have sold more than 50 million albums worldwide, and have had eight UK number one singles. The Gallagher brothers are the band\'s leading songwriters and the only continual members. The present lineup is completed by rhythm/lead guitarist and songwriter Gem Archer, guitarist and songwriter Andy Bell and as-yet unofficial drummer Zak Starkey.

Click here to learn more about Oasis.

');echo $acc->output(),'';

When creating the accordion, pass in the CSS class given to each toggler element and the CSS class given to each content element. Then it's time to add accordion items. For each item you want to create, pass in the toggler's content, the item's content, and whether you'd like the given item to start open. Once all of the items are in, you can call output() to output the XHTML and output_js() to output the MooTools JavaScript. You can pass to output_js() if you'd like to get fancy.

创建手风琴时,传递给每个切换器元素CSS类和给每个内容元素CSS类。 然后是时候添加手风琴了。 对于要创建的每个项目,请传递切换器的内容,该项目的内容以及是否要打开给定的项目。 输入所有项目后,您可以调用output()输出XHTML,并调用output_js()输出MooTools JavaScript。 如果您愿意,可以将其他传递给output_js() 。

If you already know how to create a MooTools accordion, I'm not sure that this class would be of any value to you. If, however, you've been struggling with creating one, this may be that little helper that gets you there.

如果您已经知道如何创建MooTools手风琴,那么我不确定该类对您是否有任何价值。 但是,如果您一直在努力创建一个,那可能就是那个帮助您的小助手。

翻译自:

mootools

转载地址:http://ivpwd.baihongyu.com/

你可能感兴趣的文章
bzoj1059 [ZJOI2007]矩阵游戏
查看>>
插入返回ibatis 的selectKey 实现插入数据后获得id
查看>>
vim 程序编辑器
查看>>
LIS(单调队列优化 C++ 版)(施工ing)
查看>>
刚接触Vuex
查看>>
四种加载React数据的技术对比(Meteor 转)
查看>>
Airthmetic_Approching
查看>>
操作文本文件
查看>>
公司项目的几个问题
查看>>
解决win7下打开Excel2007,报“向程序发送命令时出现问题”的错误
查看>>
Velocity快速入门教程
查看>>
关于集合常见的问题
查看>>
车牌正则表达式
查看>>
Win form碎知识点
查看>>
避免使用不必要的浮动
查看>>
第一节:ASP.NET开发环境配置
查看>>
sqlserver database常用命令
查看>>
rsync远程同步的基本配置与使用
查看>>
第二天作业
查看>>
访问属性和访问实例变量的区别
查看>>