Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
101
gaia/tests/jsmarionette/client/marionette-client/lib/marionette/marionette.js
Executable file
101
gaia/tests/jsmarionette/client/marionette-client/lib/marionette/marionette.js
Executable file
|
|
@ -0,0 +1,101 @@
|
|||
(function(global, module) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Define a list of paths
|
||||
* this will only be used in the browser.
|
||||
*/
|
||||
var paths = {};
|
||||
|
||||
|
||||
/**
|
||||
* Exports object is a shim
|
||||
* we use in the browser to
|
||||
* create an object that will behave much
|
||||
* like module.exports
|
||||
*/
|
||||
function Exports(path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
Exports.prototype = {
|
||||
|
||||
/**
|
||||
* Unified require between browser/node.
|
||||
* Path is relative to this file so you
|
||||
* will want to use it like this from any depth.
|
||||
*
|
||||
*
|
||||
* var Leaf = ns.require('sub/leaf');
|
||||
*
|
||||
*
|
||||
* @param {String} path path lookup relative to this file.
|
||||
*/
|
||||
require: function exportRequire(path) {
|
||||
if (typeof(window) === 'undefined') {
|
||||
return require(require('path').join(__dirname, path));
|
||||
} else {
|
||||
return paths[path];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Maps exports to a file path.
|
||||
*/
|
||||
set exports(val) {
|
||||
return (paths[this.path] = val);
|
||||
},
|
||||
|
||||
get exports() {
|
||||
return paths[this.path];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Module object constructor.
|
||||
*
|
||||
*
|
||||
* var module = Module('sub/leaf');
|
||||
* module.exports = function Leaf(){}
|
||||
*
|
||||
*
|
||||
* @constructor
|
||||
* @param {String} path file path.
|
||||
*/
|
||||
function Module(path) {
|
||||
return new Exports(path);
|
||||
}
|
||||
|
||||
Module.require = Exports.prototype.require;
|
||||
Module.exports = Module;
|
||||
Module._paths = paths;
|
||||
|
||||
|
||||
/**
|
||||
* Reference self as exports
|
||||
* which also happens to be the constructor
|
||||
* so you can assign items to the namespace:
|
||||
*
|
||||
* //assign to Module.X
|
||||
* //assume module.exports is Module
|
||||
* module.exports.X = Foo; //Module.X === Foo;
|
||||
* Module.exports('foo'); //creates module.exports object.
|
||||
*
|
||||
*/
|
||||
module.exports = Module;
|
||||
|
||||
/**
|
||||
* In the browser assign
|
||||
* to a global namespace
|
||||
* obviously 'Module' would
|
||||
* be whatever your global namespace is.
|
||||
*/
|
||||
if (typeof(window) !== 'undefined')
|
||||
window.Marionette = Module;
|
||||
|
||||
}(
|
||||
this,
|
||||
(typeof(module) === 'undefined') ?
|
||||
{} :
|
||||
module
|
||||
));
|
||||
Loading…
Reference in a new issue