﻿/* THIS FILE CONTAINS FEATURES FOR THE NAVIGATION CONTROL */
jQuery(function() {

    // for table mode.
    jQuery('table[x-modwebdesigner-navigation-uniqueid] td:first').addClass('first');
    jQuery('table[x-modwebdesigner-navigation-uniqueid] td:last').addClass('last');



    // for bulletlist mode - works for a multilevel navigation.
    //jQuery('ul[x-modwebdesigner-navigation-uniqueid] li:first').addClass('first');
    //jQuery('ul[x-modwebdesigner-navigation-uniqueid] li:last').addClass('last');
    jQuery('ul[x-modwebdesigner-navigation-uniqueid] li').each(function() {

        // the isRootLevel is so we don't add the 'first' and 'last' classes to the children items, and only the bottom level items.
        var isRootLevel = jQuery(this).closest('ul').attr('x-modwebdesigner-navigation-uniqueid') !== undefined;

        if (jQuery(this).next().length == 0) {
            if (isRootLevel)
                jQuery(this).addClass('last');
        }
        if (jQuery(this).prev().length == 0) {
            if (isRootLevel)
                jQuery(this).addClass('first');
        }
    });



    // make sure when logged in that the editable region span itself gets a line-through, this was a problem in one case where the <del> by itself didn't render the line-through.
    jQuery('del[x-modwebdesigner-navigation-navigationitem-isactive="False"] span').css({ 'text-decoration': 'line-through' });



    // add 'odd' and 'even' class names to nodes.
    jQuery('ul[x-modwebdesigner-navigation-uniqueid] li:even').addClass('even');
    jQuery('ul[x-modwebdesigner-navigation-uniqueid] li:odd').addClass('odd');
    // now for the table displaymode.
    jQuery('table[x-modwebdesigner-navigation-uniqueid] tr:even').addClass('even');
    jQuery('table[x-modwebdesigner-navigation-uniqueid] tr:odd').addClass('odd');
    jQuery('table[x-modwebdesigner-navigation-uniqueid] td:even').addClass('even');
    jQuery('table[x-modwebdesigner-navigation-uniqueid] td:odd').addClass('odd');
});