Giter Site home page Giter Site logo

Comments (6)

annakrohn avatar annakrohn commented on July 21, 2024

@balmas, if this looks good to you I'll do the pull request and merge.

from digital_milliet.

balmas avatar balmas commented on July 21, 2024

@annakrohn I might be misreading this, but it looks to me like this would set both tabs to active if both translations are present. is this the desired behavior?

from digital_milliet.

annakrohn avatar annakrohn commented on July 21, 2024

It should break out of the assignment once it hits the first translation that has text, but my js isn't fantastic so I could be wrong.

from digital_milliet.

balmas avatar balmas commented on July 21, 2024

ah, I missed that return statement there. Generally, I think I try to avoid returns out of loop statements. I think I would probably do something like:

var available_langs = [];
$('#lang_tabs a').each(function() {
    if ($('#' + this.getAttribute('aria-controls')+ ' p')[0].innerHTML.length > 0) {
        available_langs.push(this);
});
if (available_langs.length > 0) {
    available_langs[0].addClass("active").tab('show');
}

It's not as concise, but it makes the intent of the code easier to understand.

from digital_milliet.

annakrohn avatar annakrohn commented on July 21, 2024

Changed in commit 31a40f5.

The array was being funny though, changes to objects in it didn't seem to effect the DOM, so I instead saved an attribute to use when setting the active tab.

from digital_milliet.

balmas avatar balmas commented on July 21, 2024

ok thanks! this is fine to merge.

from digital_milliet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.