• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

[MooTools] Funktionserklärung 'slice'

Animal21

Neues Mitglied
Hallo Leute,

ich nutze auf meiner seite das framework mootools und speziell ein "tabControl" von einem user, welches ich nun gern für meine zwecke umändern würde...
leider versteh ich den sinn und zweck der rot-markierten stelle nicht, also was bringt das genau:

Hier die komplette Funktion:
Code:
        var sideTab = new Class({
        Implements: 
            [Events, Options], 
            options: { navActiveClass: 'selected'
        },    
        initialize: function(tabsNav, tabsBody, options){
            this.setOptions(options);
            this.tNav = tabsNav;
            this.tBody = tabsBody; 
            this.attach();
        }, 
        attach: function(){
            this.tNav.each(function(tab, index){
                tab.addEvent('click', this.resize.bindWithEvent(this, index));
            }, this);
        }, 
        resize: function(e, index){
            e.stop();
            
            this.tBodyCont = this.tBody.getParent();
            this.tNavCont = this.tNav.getParent();

            this.tBody.set('styles', {
                'position': 'absolute',
                'top': 0,
                'opacity': 0
            }).fade('out');
     
            // show the active content item
            this.tBody[index].set('styles', {
                'display': 'block',
                'opacity': 0
            }).fade('in');
            
            // add class to the active tab
            this.tNavCont.removeClass(this.options.navActiveClass);
            this.tNavCont[index].addClass(this.options.navActiveClass);
        }
    });

    Elements.implement({
        tabify: function(options){
[COLOR=red]            this.tabNav = this.slice(0, this.length / 2);
            this.tabBody = this.slice(3, this.length);[/COLOR]
            new sideTab($$(this.tabNav), $$(this.tabBody), $pick(options, {}));
        }
    });
    window.addEvent('load', function() {
          $$('#tabs-nav a, #tabs-body li').tabify({
        });
    });
dies ist das original, das tabs-nav ist eine ul, sowie der tab-body...

Also ich weis was slice macht (sowas wie substring bei c#), aber warum an dieser stelle...?

mfg
ani
 
Werbung:
Werbung:
Zurück
Oben