Note that there are some explanatory texts on larger screens.

plurals
  1. POprototype object.extend
    primarykey
    data
    text
    <p>In below code, I can create a instance by using:</p> <p>new TabBuilder();</p> <p>Now, I try to create a instance with different config value, I use:</p> <p>new TabBuilder({effect:'none', duration:500, tabContainer:'.tab-new', tab:'.tab'}) </p> <p>But it is not work, anybody can help?</p> <pre><code>var TabBuilder = Class.create(); TabBuilder.prototype = { config: { effect: 'none', duration: 300, tabContainer: '.tab-container', tab: '.tab' }, initialize: function(settings) { Object.extend(this.config, settings); $$(this.config.tabContainer).each(function(el){ this.buildTabs(el) .setActiveTab(el, 0) .addObservers(el); }.bind(this)) }, buildTabs: function(container) { var tabs = new Element('ol') .addClassName('tabs'); container.insert({'bottom': tabs}); var tabsContent = new Element('div') .addClassName('content') tabs.insert({'after': tabsContent}); $(container).select(this.config.tab).each(function(el) { var tab = $(el).select('.head')[0].wrap('li'); tabs.insert({'bottom': tab}); var tabContent = $(el).select('.content')[0]; tabContent.removeClassName('content').addClassName('tab'); tabsContent.insert({'bottom': tabContent}); $(el).remove(); }) $$('.tabs li:first-child')[0].addClassName('first'); $$('.tabs li:last-child')[0].addClassName('last'); return this; }, setActiveTab: function(container, index) { this._switchTabDisplay(container, index); return this; }, addObservers: function(container) { var that = this; $(container).select('.tabs li').each(function(el, index) { el.observe('mouseover', function() { that.setActiveTab(container, index) }); el.observe('mouseover', function(el) { $(this).addClassName('over'); }) el.observe('mouseout', function(el) { $(this).removeClassName('over'); }) }) return this; }, _switchTabDisplay: function(container, index) { $(container).select('.tabs li, .content .tab').invoke('removeClassName', 'active'); $(container).select('.tabs li')[index].addClassName('active'); $(container).select('.content .tab')[index].addClassName('active'); $(container).select('.content .tab').invoke('setStyle', {'display': 'none'}); $(container).select('.content .tab')[index].setStyle({'display': 'block'}); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload