+ },
+
+ observe : Element.Methods.observe.wrap(function(proceed, element, eventName, handler) {
+ if (eventName === "contentchange") {
+ proceed(element, 'keyup', function(evt) {
+ if (evt.keyCode === 13) {
+ return;
+ }
+ handler.apply(null, arguments);
+ });
+ proceed(element, 'paste', handler.defer.bind(handler));
+ return proceed(element, 'change', handler);
+ }
+ return proceed(element, eventName, handler);
+ }),
+
+ timedobserve: function(element, callback, delay) {
+ var timeout = null, initialvalue = element.value;
+
+ if (typeof delay !== "number") {
+ delay = 0.5;
+ }
+ delay = delay * 1000;
+
+ var canceltimer = function() {
+ if (timeout) {
+ clearTimeout(timeout);
+ timeout = null;
+ }
+ };
+ var resettimer = function() {
+ canceltimer();
+ timeout = setTimeout(triggercallback, delay);
+ };
+ var triggercallback = function() {
+ canceltimer();
+ if (initialvalue !== element.value) {
+ initialvalue = element.value;
+ callback.call(element);
+ }
+ };
+
+ element.observe('blur', triggercallback).
+ observe('keyup', resettimer).
+ observe('paste', resettimer);
+ return element;