jeff.pace

need help migrating to AMD

Discussion created by jeff.pace on Aug 21, 2013
Latest reply on Aug 22, 2013 by zj_zou
So i have a utilities folder with a common.js that contains a bunch of helper methods.  Pre AMD it looked like.  NO idea how to migrate to AMD.  THANKS!

dojo.provide("utilities.common");

utilities.common.getType = function(value) {
    var type = "config.json";
    switch (value) {
        case "test":
            type = "config-test.json";
            break
        case "landdevelopment":
            type = "config-landdevelopment.json";
            break
        case "utilitiesinfrastructure":
            type = "config-utilitiesinfrastructure.json";
            break
        default:
            type = "config.json";

    }

    return type;
};

utilities.common.getFormattedServiceType = function(value) {
    var type = "Property Locator";
    var newValue = (value.replace(".json", "")).replace('config-', '');
    switch (newValue) {
        case "test":
            type = "Test";
            break
        case "landdevelopment":
            type = "Land Development";
            break
        case "utilitiesinfrastructure":
            type = "Utilities Infrastructure";
            break
        default:
            type = "Property Locator";

    }

    return type;
};

utilities.common.getAllNamedChildDijits = function(id) {
    // Gather all child widgets
    var w = null;
    var children = null;
    widgets = {};
    w = dojo.query("[widgetId]", dojo.byId(id));
    children = w.map(dijit.byNode);
    children.forEach(function(item, idx) {
        if (item.name) {
            widgets[item.name] = item;
        }
    });


    return widgets;

};

Outcomes