generators/jelly/templates/javascripts/jelly.js in honkster-jelly-0.8.11 vs generators/jelly/templates/javascripts/jelly.js in honkster-jelly-0.8.12

- old
+ new

@@ -1,10 +1,10 @@ /** * Jelly. a sweet unobtrusive javascript framework * for jQuery and Rails * - * version 0.8.11 + * version 0.8.12 * * Copyright (c) 2009 Pivotal Labs * Licensed under the MIT license. * * * Date: 2009-07-20 9:50:50 (Mon, 20 Jul 2009) @@ -60,44 +60,49 @@ if (observer) { this.push(observer); } }, - notify: function(callbacks) { + notify: function(instructions) { if (this == Jelly) { return Jelly.Observers.notify.apply(this.observers, arguments); } - if (!$.isArray(callbacks)) { - callbacks = [callbacks]; + if (!$.isArray(instructions)) { + instructions = [instructions]; } var pristineObservers = this.slice(0); var observers; - for (var i = 0; i < callbacks.length; i++) { - var callback = callbacks[i]; + for (var i = 0; i < instructions.length; i++) { + var instruction = instructions[i]; // Deprecate 'on' in favor of making each page action a Component. - if (callback.on) { - observers = [eval(callback.on)]; + if (instruction.on) { + observers = [eval(instruction.on)]; } else { observers = pristineObservers; } - if (callback.method) { + if (instruction.method) { for (var j = 0; j < observers.length; j++) { var observer = observers[j]; - if (observer[callback.method]) { - if (observer.detach && observer.detach()) { - Jelly.Observers.garbageCollectObserver.call(this, observer); - } else { - observer[callback.method].apply(observer, callback.arguments); - } - } + Jelly.Observers.notifyObserver.call(this, observer, instruction.method, instruction.arguments); + Jelly.Observers.notifyObserver.call(this, observer, 'on_notify', [instruction]); } } - if (callback.attach) { - Jelly.Observers.attach.apply(this, callback.attach); + if (instruction.attach) { + Jelly.Observers.attach.apply(this, instruction.attach); + } + } + }, + + notifyObserver: function(observer, method, arguments) { + if (observer[method]) { + if (observer.detach && observer.detach()) { + Jelly.Observers.garbageCollectObserver.call(this, observer); + } else { + observer[method].apply(observer, arguments); } } }, garbageCollectObserver: function(observer) {