Вход Регистрация
Файл: tyde/www/web/js/core/switcher.js
Строк: 394
<?php
/*! UIkit 2.24.3 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(UI) {

    
"use strict";

    var 
Animations;

    
UI.component('switcher', {

        
defaults: {
            
connect   false,
            
toggle    ">*",
            
active    0,
            
animation false,
            
duration  200,
            
swiping   true
        
},

        
animatingfalse,

        
boot: function() {

            
// init code
            
UI.ready(function(context) {

                
UI.$("[data-uk-switcher]"context).each(function() {
                    var 
switcher UI.$(this);

                    if (!
switcher.data("switcher")) {
                        var 
obj UI.switcher(switcherUI.Utils.options(switcher.attr("data-uk-switcher")));
                    }
                });
            });
        },

        
init: function() {

            var 
$this this;

            
this.on("click.uikit.switcher"this.options.toggle, function(e) {
                
e.preventDefault();
                
$this.show(this);
            });

            if (
this.options.connect) {

                
this.connect UI.$(this.options.connect);

                
this.connect.find(".uk-active").removeClass(".uk-active");

                
// delegate switch commands within container content
                
if (this.connect.length) {

                    
// Init ARIA for connect
                    
this.connect.children().attr('aria-hidden''true');

                    
this.connect.on("click"'[data-uk-switcher-item]', function(e) {

                        
e.preventDefault();

                        var 
item UI.$(this).attr('data-uk-switcher-item');

                        if (
$this.index == item) return;

                        switch(
item) {
                            case 
'next':
                            case 
'previous':
                                
$this.show($this.index + (item=='next' 1:-1));
                                break;
                            default:
                                
$this.show(parseInt(item10));
                        }
                    });

                    if (
this.options.swiping) {

                        
this.connect.on('swipeRight swipeLeft', function(e) {
                            
e.preventDefault();
                            if(!
window.getSelection().toString()) {
                                
$this.show($this.index + (e.type == 'swipeLeft' : -1));
                            }
                        });
                    }
                }

                var 
toggles this.find(this.options.toggle),
                    
active  toggles.filter(".uk-active");

                if (
active.length) {
                    
this.show(activefalse);
                } else {

                    if (
this.options.active===false) return;

                    
active toggles.eq(this.options.active);
                    
this.show(active.length active toggles.eq(0), false);
                }

                
// Init ARIA for toggles
                
toggles.not(active).attr('aria-expanded''false');
                
active.attr('aria-expanded''true');

                
this.on('changed.uk.dom', function() {
                    
$this.connect UI.$($this.options.connect);
                });
            }

        },

        
show: function(tabanimate) {

            if (
this.animating) {
                return;
            }

            if (
isNaN(tab)) {
                
tab UI.$(tab);
            } else {

                var 
toggles this.find(this.options.toggle);

                
tab tab toggles.length-tab;
                
tab toggles.eq(toggles[tab] ? tab 0);
            }

            var 
$this     this,
                
toggles   this.find(this.options.toggle),
                
active    UI.$(tab),
                
animation Animations[this.options.animation] || function(currentnext) {

                    if (!
$this.options.animation) {
                        return 
Animations.none.apply($this);
                    }

                    var 
anim $this.options.animation.split(',');

                    if (
anim.length == 1) {
                        
anim[1] = anim[0];
                    }

                    
anim[0] = anim[0].trim();
                    
anim[1] = anim[1].trim();

                    return 
coreAnimation.apply($this, [animcurrentnext]);
                };

            if (
animate===false || !UI.support.animation) {
                
animation Animations.none;
            }

            if (
active.hasClass("uk-disabled")) return;

            
// Update ARIA for Toggles
            
toggles.attr('aria-expanded''false');
            
active.attr('aria-expanded''true');

            
toggles.filter(".uk-active").removeClass("uk-active");
            
active.addClass("uk-active");

            if (
this.options.connect && this.connect.length) {

                
this.index this.find(this.options.toggle).index(active);

                if (
this.index == -) {
                    
this.index 0;
                }

                
this.connect.each(function() {

                    var 
container UI.$(this),
                        
children  UI.$(container.children()),
                        
current   UI.$(children.filter('.uk-active')),
                        
next      UI.$(children.eq($this.index));

                        
$this.animating true;

                        
animation.apply($this, [currentnext]).then(function(){

                            
current.removeClass("uk-active");
                            
next.addClass("uk-active");

                            
// Update ARIA for connect
                            
current.attr('aria-hidden''true');
                            
next.attr('aria-hidden''false');

                            
UI.Utils.checkDisplay(nexttrue);

                            
$this.animating false;

                        });
                });
            }

            
this.trigger("show.uk.switcher", [active]);
        }
    });

    
Animations = {

        
'none': function() {
            var 
UI.$.Deferred();
            
d.resolve();
            return 
d.promise();
        },

        
'fade': function(currentnext) {
            return 
coreAnimation.apply(this, ['uk-animation-fade'currentnext]);
        },

        
'slide-bottom': function(currentnext) {
            return 
coreAnimation.apply(this, ['uk-animation-slide-bottom'currentnext]);
        },

        
'slide-top': function(currentnext) {
            return 
coreAnimation.apply(this, ['uk-animation-slide-top'currentnext]);
        },

        
'slide-vertical': function(currentnextdir) {

            var 
anim = ['uk-animation-slide-top''uk-animation-slide-bottom'];

            if (
current && current.index() > next.index()) {
                
anim.reverse();
            }

            return 
coreAnimation.apply(this, [animcurrentnext]);
        },

        
'slide-left': function(currentnext) {
            return 
coreAnimation.apply(this, ['uk-animation-slide-left'currentnext]);
        },

        
'slide-right': function(currentnext) {
            return 
coreAnimation.apply(this, ['uk-animation-slide-right'currentnext]);
        },

        
'slide-horizontal': function(currentnextdir) {

            var 
anim = ['uk-animation-slide-right''uk-animation-slide-left'];

            if (
current && current.index() > next.index()) {
                
anim.reverse();
            }

            return 
coreAnimation.apply(this, [animcurrentnext]);
        },

        
'scale': function(currentnext) {
            return 
coreAnimation.apply(this, ['uk-animation-scale-up'currentnext]);
        }
    };

    
UI.switcher.animations Animations;


    
// helpers

    
function coreAnimation(clscurrentnext) {

        var 
UI.$.Deferred(), clsIn clsclsOut clsrelease;

        if (
next[0]===current[0]) {
            
d.resolve();
            return 
d.promise();
        }

        if (
typeof(cls) == 'object') {
            
clsIn  cls[0];
            
clsOut cls[1] || cls[0];
        }

        
UI.$body.css('overflow-x''hidden'); // fix scroll jumping in iOS

        
release = function() {

            if (
currentcurrent.hide().removeClass('uk-active '+clsOut+' uk-animation-reverse');

            
next.addClass(clsIn).one(UI.support.animation.end, function() {

                
next.removeClass(''+clsIn+'').css({opacity:''display:''});

                
d.resolve();

                
UI.$body.css('overflow-x''');

                if (
currentcurrent.css({opacity:''display:''});

            }.
bind(this)).show();
        };

        
next.css('animation-duration'this.options.duration+'ms');

        if (
current && current.length) {

            
current.css('animation-duration'this.options.duration+'ms');

            
current.css('display''none').addClass(clsOut+' uk-animation-reverse').one(UI.support.animation.end, function() {
                
release();
            }.
bind(this)).css('display''');

        } else {
            
next.addClass('uk-active');
            
release();
        }

        return 
d.promise();
    }

})(
UIkit);
?>
Онлайн: 1
Реклама