javascript Nexternal的Javascript片段集合

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Nexternal的Javascript片段集合相关的知识,希望对你有一定的参考价值。

// Product Detail Tabs
var tabContainer = '<div class="tabs"><ul class="nav-tab"><li class="tab1 active"><a href="tab1-link"></a></li><li class="tab2"><a href="tab2-link"></a></li></ul></div>';
var tabContent = '<ul class="tab-content"><li><div id="tab1-content" style="display: block;"></div></li><li><div id="tab2-content" style="display: none;"></div></li></ul>';
var tab1Heading = nextQuery('#tabMotion .customTab1Heading').first().contents();
var tab2Heading = nextQuery('#tabMotion .customTab1Heading').last().contents();
if (nextQuery('body').hasClass('nextProductDetail')) {
    nextQuery(tabContainer).insertAfter('body.nextProductDetail .nextTabbedDetails');
    nextQuery(tab1Heading).appendTo('.tab1 a');
    nextQuery(tab2Heading).appendTo('.tab2 a');
    nextQuery(tabContent).insertAfter('body.nextProductDetail .tabs');
    nextQuery('.nextReviewsQuestions4').contents().appendTo('#tab1-content');
    nextQuery('.nextReviewsQuestions5').contents().appendTo('#tab2-content');

    nextQuery('.nav-tab li').click(function(e) {
        e.preventDefault();
        if (!nextQuery(this).hasClass('active') && nextQuery(this).hasClass('tab1')) {
            nextQuery(this).addClass('active');
            nextQuery('#tab1-content').show();
            nextQuery(this).siblings().removeClass('active');
            nextQuery('#tab2-content').hide();
        } else if (!nextQuery(this).hasClass('active') && nextQuery(this).hasClass('tab2')) {
            nextQuery(this).addClass('active');
            nextQuery('#tab2-content').show();
            nextQuery(this).siblings().removeClass('active');
            nextQuery('#tab1-content').hide();
        } else if (nextQuery(this).hasClass('active')) {
            return;
        } 
    });
    
    if (!nextQuery('body.nextProductDetail .customTab1Heading').length) {
        nextQuery('body.nextProductDetail .tabs').hide();
        nextQuery('body.nextProductDetail .tab-content').hide();
    }
}

// Wrap Second column on PD page
nextQuery('.nextProductDetail .nextTabbedProduct').wrapInner('<div class="inner"></div>');

// Wrap Threadwrapper on PD Page
nextQuery('.nextProductDetail #threadWrapper').wrapInner('<div class="bread_container"></div>');

// Change Banner and text on PL page
if (nextQuery('body').hasClass('nextProductList')) {
    if (nextQuery('body').hasClass('nextCategory2')) {
        nextQuery('#shop-banner').css('background-image', 'url(https://www.nexternal.com/clifwine/images/shop-banner-wine.jpg');
        nextQuery('#shop-banner .u-inner').html('<i>Tasty</i> Wines');
    } 
    else if (nextQuery('body').hasClass('nextCategory3')) {
        nextQuery('#shop-banner').css('background-image', 'url(https://www.nexternal.com/clifwine/images/shop-foods.png');
        nextQuery('#shop-banner .u-inner').html('<i>Artisan</i> Foods');
    }
    else if (nextQuery('body').hasClass('nextCategory4')) {
        nextQuery('#shop-banner').css('background-image', 'url(https://www.nexternal.com/clifwine/images/shop-merch.png');
        nextQuery('#shop-banner .u-inner').html('Merchandise');
    }
    else if (nextQuery('body').hasClass('nextCategory5')) {
        nextQuery('#shop-banner').css('background-image', 'url(https://www.nexternal.com/clifwine/images/shop-gift.png');
        nextQuery('#shop-banner .u-inner').html('<i>Gift</i> Giving');
    }
}

// Change Active Class on Nav depending on category class
var categories = ['nextCategory2', 'nextCategory3', 'nextCategory4', 'nextCategory5'];

categories.forEach(function(cat, i) {
    if (document.body.classList.contains(cat)) {
        var navItems = document.querySelectorAll('.categories li');
        navItems.forEach(function(navItem) {
            if (navItem.classList.contains(cat)) {
                navItem.classList.add('active');
            }
        });
    }
});

// Product Detail ATC Table
var cartTable = '<table class="atc-table"><thead><tr><th>Quantity</th><th>Retail</th><th>Wine Club</th></tr></thead><tbody><tr><td class="atc-price"></td><td class="atc-club"></td></tr></tbody></table>';
nextQuery(cartTable).insertBefore('.nextProductDetail .tabs');
nextQuery('.nextProductDetail .nextAddToCartQuantity').prependTo('.atc-table tbody > tr');
nextQuery('.nextProductDetail .nextPriceWrapper span').appendTo('.atc-price');
nextQuery('.nextProductDetail .nextPrice.clubPrice b').appendTo('.atc-club');
nextQuery('.nextProductDetail .nextPrice').hide();

if (nextQuery('.nextProductDetail .atc-club').is(':empty')) {
    nextQuery('.atc-club').hide();
    nextQuery('.atc-table th').last().hide();
    nextQuery('.atc-table th:nth-child(2)').css('border-right', 'none');
    nextQuery('.atc-table .atc-price').last().css('border-right', 'none');
}

// Move ATC Button
nextQuery('.nextProductDetail .nextAddToCartTable').insertAfter('.atc-table');

// Move Ship To Options
nextQuery('.nextProductDetail .nextTabbedDetails').insertAfter('.atc-table');

// Move Product Title and Price above Prodlist Image
if (nextQuery('body').hasClass('nextProductList')) {
    nextQuery('body.nextProductList .tileContent').each(function(index, element) {
        nextQuery(this).children('.nextPrice').prependTo(this);
        nextQuery(this).children('.nextProdName').prependTo(this);
        nextQuery(this).find('.nextCustomField2 b').prependTo(nextQuery(this).children('.nextPrice')).append('<span style="padding:0 5px;"> | </span>');
        nextQuery(this).find('.nextCustomField2').hide();
        nextQuery(this).find('.clubPrice').hide();
    });
}
if (nextQuery('body').hasClass('nextProductDetail')) {
    if (nextQuery('.atc-price strike').length) {
        nextQuery('.atc-price span').last().hide();
        nextQuery('')
    }
}

以上是关于javascript Nexternal的Javascript片段集合的主要内容,如果未能解决你的问题,请参考以下文章

java获取javascript的内容

java如何执行javascript操作html

JavaScript和Java的区别?

Java/JavaScript - java.time.Instant 序列化为 javascript Date [重复]

java和JavaScript的区别

java和JavaScript的区别