Skip to content

Commit

Permalink
fixed some mootools bugs and added .submit method to ELEMENT
Browse files Browse the repository at this point in the history
  • Loading branch information
brettwejrowski committed Jun 12, 2012
1 parent dfe3b53 commit c1a033d
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 71 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ downloads area
v3.0.5 changelog
- moved beforeCheckout event and form sending inside of .checkout() to keep dry
- added price, shipping, tax formatting for paypal checkout
- added .submit method to ELEMENT
- fixed mootools .get and .live bugs


## Quick Start
Expand Down
54 changes: 30 additions & 24 deletions simpleCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Copyright (c) 2012 Brett Wejrowski
wojodesign.com
simplecartjs.com
simplecartjs.org
http://github.com/wojodesign/simplecart-js
VERSION 3.0.4
Expand All @@ -12,7 +12,6 @@
/*jslint browser: true, unparam: true, white: true, nomen: true, regexp: true, maxerr: 50, indent: 4 */

(function (window, document) {
//"use strict";
/*global HTMLElement */

var typeof_string = typeof "",
Expand Down Expand Up @@ -1401,7 +1400,7 @@
},
attr: function (attr, val) {
if (isUndefined(val)) {
return this.el.get(attr);
return this.el[0] && this.el[0].get(attr);
}

this.el.set(attr, val);
Expand All @@ -1425,7 +1424,9 @@
},
each: function (callback) {
if (isFunction(callback)) {
simpleCart.each(this.el, callback);
simpleCart.each(this.el, function( e, i, c) {
callback.call( i, i, e, c );
});
}
return this;
},
Expand All @@ -1445,11 +1446,8 @@
live: function ( event,callback) {
var selector = this.selector;
if (isFunction(callback)) {
simpleCart.$(document).el.addEvent(event, function (e) {
var target = simpleCart.$(e.target);
if (target.match(selector)) {
callback.call(target, e);
}
simpleCart.$("body").el.addEvent(event + ":relay(" + selector + ")", function (e, el) {
callback.call(el, e);
});
}
},
Expand All @@ -1471,8 +1469,10 @@
tag: function () {
return this.el[0].tagName;
},


submit: function (){
this.el[0].submit();
return this;
},
create: function (selector) {
this.el = $engine(selector);
}
Expand All @@ -1485,7 +1485,7 @@
if (isUndefined(text)) {
return this.el[0].innerHTML;
}
this.each(function (e) {
this.each(function (i,e) {
$(e).update(text);
});
return this;
Expand All @@ -1500,15 +1500,15 @@
if (isUndefined(val)) {
return this.el[0].readAttribute(attr);
}
this.each(function (e) {
this.each(function (i,e) {
$(e).writeAttribute(attr, val);
});
return this;
},
append: function (item) {
this.each(function (e) {
this.each(function (i,e) {
if (item.el) {
item.each(function (e2) {
item.each(function (i2,e2) {
$(e).appendChild(e2);
});
} else if (isElement(item)) {
Expand All @@ -1518,38 +1518,40 @@
return this;
},
remove: function () {
this.each(function (e) {
this.each(function (i, e) {
$(e).remove();
});
return this;
},
addClass: function (klass) {
this.each(function (e) {
this.each(function (i, e) {
$(e).addClassName(klass);
});
return this;
},
removeClass: function (klass) {
this.each(function (e) {
this.each(function (i, e) {
$(e).removeClassName(klass);
});
return this;
},
each: function (callback) {
if (isFunction(callback)) {
simpleCart.each(this.el, callback);
simpleCart.each(this.el, function( e, i, c) {
callback.call( i, i, e, c );
});
}
return this;
},
click: function (callback) {
if (isFunction(callback)) {
this.each(function (e) {
this.each(function (i, e) {
$(e).observe(_CLICK_, function (ev) {
callback.call(e,ev);
});
});
} else if (isUndefined(callback)) {
this.each(function (e) {
this.each(function (i, e) {
$(e).fire(_CLICK_);
});
}
Expand Down Expand Up @@ -1580,7 +1582,9 @@
tag: function () {
return this.el.tagName;
},

submit: function() {
this.el[0].submit();
},

create: function (selector) {
if (isString(selector)) {
Expand All @@ -1594,7 +1598,7 @@

},

"jQuery" : {
"jQuery": {
passthrough: function (action, val) {
if (isUndefined(val)) {
return this.el[action]();
Expand Down Expand Up @@ -1661,7 +1665,9 @@
descendants: function () {
return simpleCart.$(this.el.find("*"));
},

submit: function() {
return this.el.submit();
},

create: function (selector) {
this.el = $engine(selector);
Expand Down
Loading

0 comments on commit c1a033d

Please sign in to comment.