Skip to content

Commit

Permalink
Removed extensibility from core
Browse files Browse the repository at this point in the history
  • Loading branch information
bmavity committed Oct 1, 2011
1 parent 9d045dd commit 83d4cf6
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 146 deletions.
9 changes: 9 additions & 0 deletions caruso.init.wagner.js
@@ -0,0 +1,9 @@
(function() {
var module = new wagner.Module(), exports = module.exports, define = module.define, component = module.component;
define('component.init.caruso', function(component, caruso, decorate) {
component.addToChain('creating environment', 'caruso', function(input, env, next) {
decorate.merge(env, caruso.bindElement(input.$ele));
next();
});
});
})();
160 changes: 14 additions & 146 deletions caruso.js
@@ -1,140 +1,6 @@
;(function(module) {
(function(exports, define) {
define('util', function() {
var isArray = function(x) {
return Object.prototype.toString.call(x) === "[object Array]";
};

var isFunction = function(x) {
return Object.prototype.toString.call(x) === "[object Function]";
};

var isNumber = function(x) {
return Object.prototype.toString.call(x) === "[object Number]";
};

var isString = function(x) {
return Object.prototype.toString.call(x) === "[object String]";
};

exports.isArray = isArray;
exports.isFunction = isFunction;
exports.isNumber = isNumber;
exports.isString = isString;
});
})(typeof exports !== 'undefined' ? exports : module.exports
, typeof define !== 'undefined' ? define : function(name, factoryFn) {
factoryFn();
window[name] = module.exports;
}
);
})(typeof module !== 'undefined' ? module : { exports: {} });

;(function(module) {
(function(exports, define) {
define('oi', function() {
var forIn = function(obj, callback) {
getKeys(obj).forEach(function(key) {
callback(key, obj[key]);
});
};

var getKeys = function(obj) {
return Object.keys(obj);
};

var iter = function(obj) {
var keys = getKeys(obj)
, i = 0
;

var hasNext = function() {
return !!keys[i];
};

var next = function(callback) {
var key = keys[i]
, val = obj[key]
;
i++;
callback(key, val);
};

return {
hasNext: hasNext
, next: next
};
};

exports.forIn = forIn;
exports.iter = iter;
});
})(typeof exports !== 'undefined' ? exports : module.exports
, typeof define !== 'undefined' ? define : function(name, factoryFn) {
factoryFn();
window[name] = module.exports;
}
);
})(typeof module !== 'undefined' ? module : { exports: {} });

;(function(module) {
(function(exports, define) {
define('chains', function() {
function FunctionChainer() {
var registrations = {}
, noop = function() {}
;

var executeChain = function(evt, data, end) {
var args = Array.prototype.slice.call(arguments, 1)
, lastEle = args.slice(-1)[0]
, it = oi.iter(registrations[evt])
;

if(util.isFunction(lastEle)) {
end = args.pop();
}

var executeHandler = function(key, val) {
var nextFn
;
if(it.hasNext()) {
nextFn = function() {
it.next(executeHandler);
};
} else {
nextFn = noop;
}
val.apply(null, args.concat([nextFn]));
};
if(it.hasNext()) {
it.next(executeHandler);
}
end && end();
};

var addToChain = function(evt, name, fn) {
registrations[evt] = registrations[evt] || {};
registrations[evt][name] = fn;
};

this.addToChain = addToChain;
this.executeChain = executeChain;
};

exports.FunctionChainer = FunctionChainer;
});
})(typeof exports !== 'undefined' ? exports : module.exports
, typeof define !== 'undefined' ? define : function(name, factoryFn) {
factoryFn();
window[name] = module.exports;
}
);
})(typeof module !== 'undefined' ? module : { exports: {} });

;(function(module) {
(function(exports, define) {
define('caruso', function(util, oi, chain) {
define('caruso', function(util, oi, chain, http) {
var chainer = new chain.FunctionChainer();
module.exports = exports = chainer;

Expand Down Expand Up @@ -186,16 +52,18 @@
locationResult = {};
chainer.executeChain('matching element', locationArgs, locationResult, function() {
var $match = locationResult.$match;
if(util.isString(val) || util.isNumber(val)) {
chainer.executeChain('setting value', {
$match: $match
, val: val
});
} else {
if(util.isArray(val)) {
injectArray($match, val);
if($match) {
if(util.isString(val) || util.isNumber(val)) {
chainer.executeChain('setting value', {
$match: $match
, val: val
});
} else {
injectSingle($match, val);
if(util.isArray(val)) {
injectArray($match, val);
} else {
injectSingle($match, val);
}
}
}
});
Expand All @@ -204,7 +72,7 @@

var dataSource = function(source) {
if(util.isString(source)) {
$.get(source, function(res) {
http.get(source, function(res) {
inject(data);
});
} else {
Expand Down Expand Up @@ -232,7 +100,7 @@
});
})(typeof exports !== 'undefined' ? exports : module.exports
, typeof define !== 'undefined' ? define : function(name, factoryFn) {
factoryFn(window.util, window.oi, window.chains);
factoryFn(window.util, window.oi, window.chains, window.http);
window[name] = module.exports;
}
);
Expand Down
153 changes: 153 additions & 0 deletions mav.js
@@ -0,0 +1,153 @@
;(function(module) {
(function(exports, define) {
define('util', function() {
var isArray = function(x) {
return Object.prototype.toString.call(x) === "[object Array]";
};

var isFunction = function(x) {
return Object.prototype.toString.call(x) === "[object Function]";
};

var isNumber = function(x) {
return Object.prototype.toString.call(x) === "[object Number]";
};

var isString = function(x) {
return Object.prototype.toString.call(x) === "[object String]";
};

exports.isArray = isArray;
exports.isFunction = isFunction;
exports.isNumber = isNumber;
exports.isString = isString;
});
})(typeof exports !== 'undefined' ? exports : module.exports
, typeof define !== 'undefined' ? define : function(name, factoryFn) {
factoryFn();
window[name] = module.exports;
}
);
})(typeof module !== 'undefined' ? module : { exports: {} });

;(function(module) {
(function(exports, define) {
define('oi', function() {
var forIn = function(obj, callback) {
getKeys(obj).forEach(function(key) {
callback(key, obj[key]);
});
};

var getKeys = function(obj) {
return Object.keys(obj);
};

var iter = function(obj) {
var keys = getKeys(obj)
, i = 0
;

var hasNext = function() {
return !!keys[i];
};

var next = function(callback) {
var key = keys[i]
, val = obj[key]
;
i++;
callback(key, val);
};

return {
hasNext: hasNext
, next: next
};
};

exports.forEach = forIn;
exports.forIn = forIn;
exports.iter = iter;
});
})(typeof exports !== 'undefined' ? exports : module.exports
, typeof define !== 'undefined' ? define : function(name, factoryFn) {
factoryFn();
window[name] = module.exports;
}
);
})(typeof module !== 'undefined' ? module : { exports: {} });

;(function(module) {
(function(exports, define) {
define('decorate', function(oi) {
var merge = function(obj, extendWith) {
oi.forEach(extendWith, function(name, val) {
obj[name] = val;
});
};

exports.merge = merge;
});
})(typeof exports !== 'undefined' ? exports : module.exports
, typeof define !== 'undefined' ? define : function(name, factoryFn) {
factoryFn(window.oi);
window[name] = module.exports;
}
);
})(typeof module !== 'undefined' ? module : { exports: {} });

;(function(module) {
(function(exports, define) {
define('chains', function() {
function FunctionChainer() {
var registrations = {}
, noop = function() {}
;

var executeChain = function(evt, data, end) {
var args = Array.prototype.slice.call(arguments, 1)
, lastEle = args.slice(-1)[0]
, it = oi.iter(registrations[evt] || {})
;

if(util.isFunction(lastEle)) {
end = args.pop();
}

var executeHandler = function(key, val) {
var nextFn
;
if(it.hasNext()) {
nextFn = function() {
it.next(executeHandler);
};
} else {
nextFn = noop;
}
val.apply(null, args.concat([nextFn]));
};
if(it.hasNext()) {
it.next(executeHandler);
}
end && end();
};

var addToChain = function(evt, name, fn) {
registrations[evt] = registrations[evt] || {};
registrations[evt][name] = fn;
};

this.addToChain = addToChain;
this.executeChain = executeChain;
};

exports.FunctionChainer = FunctionChainer;
});
})(typeof exports !== 'undefined' ? exports : module.exports
, typeof define !== 'undefined' ? define : function(name, factoryFn) {
factoryFn();
window[name] = module.exports;
}
);
})(typeof module !== 'undefined' ? module : { exports: {} });

0 comments on commit 83d4cf6

Please sign in to comment.