Skip to content

Commit

Permalink
fixed keypress bug in safari and namespaced behaviours bug
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.danwebb.net/external/lowpro/trunk@237 a686c101-5f17-0410-80e1-b267258107f6
  • Loading branch information
danwebb committed Jul 16, 2007
1 parent 962ccea commit b3fe35f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
13 changes: 6 additions & 7 deletions dist/lowpro.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ if (typeof Element.Methods.observe == 'undefined') Element.addMethods({
// Replace out existing event observe code with Dean Edwards' addEvent
// http://dean.edwards.name/weblog/2005/10/add-event/
Object.extend(Event, {
observe : function(el, type, func) {
el = $(el);
_observeAndCache : function(el, type, func) {
if (!func.$$guid) func.$$guid = Event._guid++;
if (!el.events) el.events = {};
var handlers = el.events[type];
Expand All @@ -212,8 +211,8 @@ Object.extend(Event, {
handlers[func.$$guid] = func;
el["on" + type] = Event._handleEvent;

if (!Event.observers) Event.observers = [];
Event.observers.push([el, type, func, false]);
if (!Event.observers) Event.observers = [];
Event.observers.push([el, type, func, false]);
},
stopObserving : function(el, type, func) {
el = $(el);
Expand Down Expand Up @@ -362,18 +361,18 @@ Behavior = {
create : function(members) {
var behavior = function() {
var behavior = arguments.callee;
if (this == window) {
if (this == window || $H(this).values().include(behavior)) {
var args = [];
for (var i = 0; i < arguments.length; i++)
args.push(arguments[i]);

return function(element) {
return function() {
var initArgs = [this].concat(args);
behavior.attach.apply(behavior, initArgs);
};
} else {
var args = (arguments.length == 2 && arguments[1] instanceof Array) ?
arguments[1] : Array.prototype.slice.call(arguments, 1);
arguments[1] : Array.prototype.slice.call(arguments, 1);

this.element = $(arguments[0]);
this.initialize.apply(this, args);
Expand Down
6 changes: 3 additions & 3 deletions src/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@ Behavior = {
create : function(members) {
var behavior = function() {
var behavior = arguments.callee;
if (this == window) {
if (this == window || $H(this).values().include(behavior)) {
var args = [];
for (var i = 0; i < arguments.length; i++)
args.push(arguments[i]);

return function(element) {
return function() {
var initArgs = [this].concat(args);
behavior.attach.apply(behavior, initArgs);
};
} else {
var args = (arguments.length == 2 && arguments[1] instanceof Array) ?
arguments[1] : Array.prototype.slice.call(arguments, 1);
arguments[1] : Array.prototype.slice.call(arguments, 1);

this.element = $(arguments[0]);
this.initialize.apply(this, args);
Expand Down
7 changes: 3 additions & 4 deletions src/eventext.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ if (typeof Element.Methods.observe == 'undefined') Element.addMethods({
// Replace out existing event observe code with Dean Edwards' addEvent
// http://dean.edwards.name/weblog/2005/10/add-event/
Object.extend(Event, {
observe : function(el, type, func) {
el = $(el);
_observeAndCache : function(el, type, func) {
if (!func.$$guid) func.$$guid = Event._guid++;
if (!el.events) el.events = {};
var handlers = el.events[type];
Expand All @@ -25,8 +24,8 @@ Object.extend(Event, {
handlers[func.$$guid] = func;
el["on" + type] = Event._handleEvent;

if (!Event.observers) Event.observers = [];
Event.observers.push([el, type, func, false]);
if (!Event.observers) Event.observers = [];
Event.observers.push([el, type, func, false]);
},
stopObserving : function(el, type, func) {
el = $(el);
Expand Down
2 changes: 1 addition & 1 deletion test/test-b-classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
});
Event.addBehavior({
'.dates' : DateSelector({ seperator : '-' }),
'.remote' : Remote.Link,
'.remote' : Remote.Link({ onCreate: function() { console.log('sdsds') } }),
'.remote_form' : Remote.Form
});
Event.onReady(function() {
Expand Down

0 comments on commit b3fe35f

Please sign in to comment.