Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark Active Triggers in Tabs #7

Closed
ebollens opened this issue Dec 28, 2013 · 0 comments
Closed

Mark Active Triggers in Tabs #7

ebollens opened this issue Dec 28, 2013 · 0 comments
Assignees

Comments

@ebollens
Copy link
Owner

Tabbed navigation in ucla-oarc-web/WebBlocks#298 demonstrates a use case where it would be awful nice to have a way of recognizing which tab target is active. Right now, there's no state modified when a trigger is active. Let's introduce a new data-active attribute for this.

First off, the initializer should be modified:

if(!_.inState(target, 'show'))
    _.addState(target, 'hide')
else
    trigger.attr('data-active', true)

Then, we need to switch this state during the click handler:

$.each(_.getState(target), function(idx,state){
    var containerMatch = state.match(/^c\[(.*)\]$/);
    if(containerMatch)
        $('[data-tabs~="'+state+'"]').each(function(){
            $.each(_.getState($(this)), function(idx,state){
                var targetMatch = state.match(/^t\[(.*)\]$/);
                if(targetMatch)
                    $('#'+targetMatch[1]).removeAttr('data-active');
            })
        })
});

$.each(_.getState(target), function(idx,state){
    var targetMatch = state.match(/^t\[(.*)\]$/);
    if(targetMatch)
        $('#'+targetMatch[1]).attr('data-active', true);
});
@ghost ghost assigned ebollens Dec 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant