jnewman / goog-amd

An AMD plugin that loads arbitrary things from the Google Loader.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

goog-amd

An AMD plugin that loads arbitrary things from the Google Loader

Quickstart

Add goog-amd to your paths:

require({
    // Other configurations...
    paths: {
        'goog': 'path/to/goog-amd',
    }
});

Configure in your require config (or inline, documented below):

require({
    goog: {
        maps: {
            version: '3.12',
            settings:{
                other_params: 'sensor=false'
            }
        },
        viz: {
            name: 'visualization',
            version: '1.0',
            settings: {
                packages: ['charteditor']
            }
        }
    }
});

Or if you're using dojo (could also go in data-dojo-config):

// goog! will look up the config on this module, it doens't matter how it gets there.
require(['dojo/_base/config'], function (config) {
    config.goog = {
        maps: {
            version: '3.12',
            settings:{
                other_params: 'sensor=false'
            }
        },
        viz: {
            name: 'visualization',
            version: '1.0',
            settings: {
                packages: ['charteditor']
            }
        }
    };
});

Then load your libraries:

require([
    'goog!viz'
], function(viz) {
    console.info(typeof viz.AreaChart === 'function'); // true
});

Or configure everything inline:

// Note the quoted strings, it matters.
require([
    'path/to/goog!name:"visualization",version:"1.0",packages:["charteditor"]'
], function(visualization) {
    console.info(typeof visualization.AreaChart === 'function'); // true
});

require([
    'path/to/goog!name:"maps",version:"3.13",other_params:"sensor=false"'
], function(maps) {
    console.info(typeof maps.Map === 'function'); // true
});

Profit!?

About

An AMD plugin that loads arbitrary things from the Google Loader.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:JavaScript 100.0%