FrontGate


// Frontage starts as the local host
Frontgate.href();// http://localhost

// get the complete url for a resource
Frontgate.href('images/image.jpg');// http://localhost/images/image.jpg

// load a script (http://localhost/js/raphael.js)
Frontgate.script('js/raphael.js');

// load a stylesheet (http://localhost/css/default.css)
Frontgate.stylesheet('css/default.css');

// load a template
Frontgate.template('templates/template.html', callback);

// load synchronized scripts
Frontgate.scripts( script1, script2, ... );

// create a remote Location
var Library = new Frontgate.Location({
    hostname: 'situs.dev',
    pathname: "/libs"
});

// load a stylesheet and synchronized scripts
Library.stylesheet('jquery-ui.css')
    .scripts('jquery-ui.core.js', 'jquery-ui.widget.js', 'jquery-ui.mouse.js');

// load a template and populate it with data using underscore
Library.script('underscore.js', function(){
    Library.template('user-data-template.html',
        function(template){
            $('#user-data').html(_.template(template, userData));
        });
});

// Project location
var Project = new Frontgate.Location({
    hostname: "situs.dev",
    pathname: "/dev/medorc"
});

Project.href();// 'http://situs.dev/dev/medorc'

// load a stylesheet; change its pathname; load a script with a callback
Project.stylesheet('styles/medorc.css')
    .attr('pathname','/concrete')
    .script('index.js', function(){
        console.log("Loaded '//situs.dev/concrete/index.js'");
});

Project.href();// 'http://situs.dev/concrete'

// Remote Location with libs
var CDN = new Frontgate.Location({
    hostname: 'cnd.dev',
    pathname: "/libs/min"
});

// load scripts
CDN.libs('$', '_', 'Backbone', function(){
    if(OS == "Android"){
        return "/touch/forAndroid.js";
    }
    return null;
});

/* Demos */