generators/jelly/templates/javascripts/jelly.js in honkster-jelly-0.10.0 vs generators/jelly/templates/javascripts/jelly.js in honkster-jelly-0.11.0
- old
+ new
@@ -1,9 +1,9 @@
/**
* Jelly. a sweet unobtrusive javascript framework for Rails
*
- * version 0.10.0
+ * version 0.11.0
*
* Copyright (c) 2009 Pivotal Labs
* Licensed under the MIT license.
*
* * Date: 2009-07-20 9:50:50 (Mon, 20 Jul 2009)
@@ -40,25 +40,39 @@
Observers:{
attach:function () {
if (this === Jelly) {
return Jelly.Observers.attach.apply(this.observers, arguments);
}
+ var self = Jelly.Observers;
for (var i = 0; i < arguments.length; i++) {
var definitionOrComponent = arguments[i];
if (definitionOrComponent.component) {
- var component = Jelly.Observers.evaluateComponent(definitionOrComponent.component);
- if (component.init) {
- var initReturnValue = component.init.apply(component, definitionOrComponent.arguments);
- if (initReturnValue === false || initReturnValue === null) {
- } else {
- Jelly.Observers.pushIfObserver.call(this, initReturnValue || component);
- }
- } else {
- Jelly.Observers.pushIfObserver.call(this, component);
- }
+ self.attachFromDefinition.call(
+ this,
+ self.evaluateComponent(definitionOrComponent.component),
+ definitionOrComponent.arguments
+ );
+ } else if (Object.prototype.toString.call(definitionOrComponent) === "[object Array]") {
+ self.attachFromDefinition.call(
+ this,
+ self.evaluateComponent(definitionOrComponent[0]),
+ definitionOrComponent.slice(1)
+ );
} else {
- Jelly.Observers.pushIfObserver.call(this, Jelly.Observers.evaluateComponent(definitionOrComponent));
+ self.pushIfObserver.call(this, Jelly.Observers.evaluateComponent(definitionOrComponent));
}
+ }
+ },
+
+ attachFromDefinition:function (component, args) {
+ if (component.init) {
+ var initReturnValue = component.init.apply(component, args);
+ if (initReturnValue === false || initReturnValue === null) {
+ } else {
+ Jelly.Observers.pushIfObserver.call(this, initReturnValue || component);
+ }
+ } else {
+ Jelly.Observers.pushIfObserver.call(this, component);
}
},
evaluateComponent:function (component) {
return eval(component);