PHP Classes
elePHPant
Icontem

File: src/Cabin/Bridge/public/bridge.js

Recommend this page to a friend!
  Classes of Scott Arciszewski  >  CMS Airship  >  src/Cabin/Bridge/public/bridge.js  >  Download  
File: src/Cabin/Bridge/public/bridge.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: CMS Airship
Content management system with security features
Author: By
Last change: Pre-1.3.0 release code review results.
Date: 2 years ago
Size: 2,365 bytes
 

Contents

Class file image Download
/**
 * CMS Airship - Collapsing Bridge Menu
 *
 * @since v1.3.0
 */
var bridgeLeftMenu = {
    "init": function (link, menu) {
        bridgeLeftMenu.initLink(link);
        bridgeLeftMenu.initMenu(menu);
    },

    "initLink": function(active) {
        var activeList = bridgeLeftMenu.getList(active);
        $(".bridge-menu a").each(function () {
            var section = $(this).attr('id');
            if (typeof section === 'string') {
                if ($.inArray(section, activeList) > -1) {
                    $(this).addClass('bridge-left-active');
                }
            }
        });
    },

    "initMenu": function(active) {
        var activeList = bridgeLeftMenu.getList(active);
        $(".bridge-collapse").each(function () {
            var section = $(this).data('section');
            if ($.inArray(section, activeList) === -1) {
                // Hide the child <ul>
                $(this).parent().find("ul").hide();
                $(this).parent().removeClass('collapse-active-container');
                $(this).removeClass('collapse-active');
            } else {
                $(this).parent().addClass('collapse-active-container');
                $(this).addClass('collapse-active');
            }
            $(this).attr('href', '#left-' + $(this).data('section').toLowerCase());
            $(this).on('click', function () {
                $(this).toggleClass('collapse-active-container');
                $(this).parent().children("ul").toggle();
                $(this).toggleClass('collapse-active');
            });
        });
    },

    "getList": function (active) {
        if (typeof(active) === "undefined") {
            return [];
        } else if (typeof(active) === "array" || typeof(active) === "object") {
            return active;
        } else if (typeof(active) === "string") {
            if (active === "") {
                return [];
            } else {
                var activeList = $.parseJSON(active);
                if (typeof(activeList) !== "array") {
                    activeList = [activeList];
                }
            }
            return activeList;
        } else {
            return [];
        }
    }
};

$(document).ready(function () {
    return bridgeLeftMenu.init(
        $("body").data('activelink'),
        $("body").data('activesubmenu')
    )
});