PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
  Classes of Scott Arciszewski  >  CMS Airship  >  src/Cabin/Bridge/public/admin_settings.js  >  Download  
File: src/Cabin/Bridge/public/admin_settings.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: CMS Airship
Content management system with security features
Author: By
Last change: Merge remote-tracking branch 'origin/master'
Date: 7 months ago
Size: 2,107 bytes
 

Contents

Class file image Download
var ledger_defaults = {
    "file": "~/tmp/logs",
    "database": "airship_logs"
};
var old_driver = "";

/**
 * Configuration toggle with a control element.
 */
var configToggle = {
    "togglers": {},

    "init": function (table, controller) {
        configToggle.togglers[controller] = table;
        configToggle.toggle(controller);
        $(controller).on('change', configToggle.onChangeHandler);
    },

    "onChangeHandler": function (e) {
        var _id = '#' + $(this).attr('id');
        if (typeof configToggle.togglers[_id] === 'string') {
            configToggle.toggle(_id);
        }
    },

    "toggle": function(_id) {
        var value = $(_id).val();
        $(configToggle.togglers[_id]).find('.config-email-toggled').each(
            function (index, element) {
                var tr = $(this).data('transport');
                console.log(tr);
                if (!tr) {
                    // Do nothing.
                    return;
                }
                if (tr.indexOf(value) >= 0) {
                    $(this).show('fast');
                } else {
                    $(this).hide('fast');
                }
            }
        );
    }
};

$(document).ready(function() {
    $("#admin_settings_accordion").accordion({
        heightStyle: "content"
    });
    $("#ledger_driver").on('change', function(e) {
        var details_el = $("#ledger_details");
        var new_driver = $("#ledger_driver").val();
        // Update label
        if (new_driver === "file") {
            $("#ledger_details_label").html("Log Directory:");
            details_el.attr('name', 'universal[ledger][path]');
        } else {
            $("#ledger_details_label").html("Database Table:");
            details_el.attr('name', 'universal[ledger][table]');
        }

        // Swap out details:
        ledger_defaults[old_driver] = details_el.val();
        details_el.val(ledger_defaults[new_driver]);

        // Update the reference to the current driver
        old_driver = new_driver;
    });
    configToggle.init("#email_config_table", "#email_transport");
});