Skip to content

Instantly share code, notes, and snippets.

@danshultz
Created April 28, 2012 19:56
Show Gist options
  • Save danshultz/2521649 to your computer and use it in GitHub Desktop.
Save danshultz/2521649 to your computer and use it in GitHub Desktop.
window.require.define("app/controllers/house_controller": function(exports, require, module) {
var HouseController = function(house) {
//initializer
this.house = house;
};
HouseController.prototype.render = function() {
//rendering...
};
HouseController.prototype.save = function() {
//save house
};
module.exports = HouseController;
});
window.require.define("app/models/door": function(exports, require, module) {
var Door = function(color) {
this.color = color;
};
module.exports = Door;
});
window.require.define("app/models/house": function(exports, require, module) {
var House = function(address) {
this.address = address;
this.doors = {};
this.windows = {};
};
House.prototype.addDoor = function(door, location) {
this.doors[location] = door;
};
House.prototype.addWindow = function(window, location) {
this.windows[location] = window;
};
module.exports = House;
});
window.require.define("app/models/window": function(exports, require, module) {
// private util used only here and scoped by the closure
var convertSize = function(size) {
return size * 2
};
var Window = function(size) {
this.size = convertSize(size);
};
module.exports = Window;
});
(function() {
// initial
this.HouseApp = {
Models: {},
Controllers: {}
};
var House = HouseApp.Models.House = function(address) {
this.address = address;
this.doors = {};
this.windows = {};
};
House.prototype.addDoor = function(door, location) {
this.doors[location] = door;
};
House.prototype.addWindow = function(window, location) {
this.windows[location] = window;
};
HouseApp.Models.Door = function(color) {
this.color = color;
};
// private util used only here and scoped by the closure
var convertSize = function(size) {
return size * 2
};
HouseApp.Models.Window = function(size) {
this.size = convertSize(size);
};
var HouseController = HouseApp.Controllers.HouseController = function(house) {
//initializer
this.house = house;
};
HouseController.prototype.render = function() {
//rendering...
};
HouseController.prototype.save = function() {
//save house
};
}).call(window);
(function() {
this.HouseApp = function() {
var house = new window.HouseApp.Models.House;
var aWindow = new window.HouseApp.Models.Window(52);
var aDoor = new window.HouseApp.Models.Door(32);
house.addDoor(aDoor);
house.addWindow(aWindow);
this.houseContoller = new window.HouseApp.Controllers.HouseController(house);
};
}).call(window);
window.require.define("house_app": function(exports, require, module) {
var Window = require("app/models/window");
var Door = require("app/models/door");
var House = require("app/models/house");
var HouseController = require("app/controllers/home_controller");
var HouseApp = function() {
var house = new House;
var aWindow = new Window(52);
var aDoor = new Door(32);
house.addDoor(aDoor);
house.addWindow(aWindow);
this.houseContoller = new HouseController(house);
};
module.exports = HouseApp
});
(function(/*! Stitch !*/) {
if (!this.require) {
var modules = {}, cache = {}, require = function(name, root) {
var path = expand(root, name), indexPath = expand(path, './index'), module, fn;
module = cache[path] || cache[indexPath]
if (module) {
return module;
} else if (fn = modules[path] || modules[path = indexPath]) {
module = {id: path, exports: {}};
cache[path] = module.exports;
fn(module.exports, function(name) {
return require(name, dirname(path));
}, module);
return cache[path] = module.exports;
} else {
throw 'module ' + name + ' not found';
}
}, expand = function(root, name) {
var results = [], parts, part;
if (/^\.\.?(\/|$)/.test(name)) {
parts = [root, name].join('/').split('/');
} else {
parts = name.split('/');
}
for (var i = 0, length = parts.length; i < length; i++) {
part = parts[i];
if (part == '..') {
results.pop();
} else if (part != '.' && part != '') {
results.push(part);
}
}
return results.join('/');
}, dirname = function(path) {
return path.split('/').slice(0, -1).join('/');
};
this.require = function(name) {
return require(name, '');
}
this.require.define = function(bundle) {
for (var key in bundle)
modules[key] = bundle[key];
};
this.require.modules = modules;
this.require.cache = cache;
}
return this.require.define;
}).call(this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment