Skip to content

Commit

Permalink
update built files
Browse files Browse the repository at this point in the history
  • Loading branch information
marianoguerra committed Mar 19, 2012
1 parent d5e7ff0 commit 72dbe0c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
17 changes: 13 additions & 4 deletions jquery.lego.requirejs.js
Expand Up @@ -23,13 +23,20 @@ define(["path/to/jquery"], function ($) {
$.lego = function (tag) {
var key, $tag, i, childs, attr, options;

// if tag is an object get the key as tag and value as options
if (typeof(tag) === "string") {
return $.lego(legoparser.parse(tag));
} else if ($.isArray(tag)) {
return $.map(tag, function (item) {
return $.lego(item);
});
if (tag.length === 1) {
if (typeof(tag[0]) === "string") {
$.lego({"div": {"$childs": tag}});
} else {
$.lego(tag[0]);
}
} else {
return $.map(tag, function (item) {
return $.lego(item);
});
}
} else {
key = getFirstKey(tag);
options = tag[key];
Expand Down Expand Up @@ -76,6 +83,8 @@ define(["path/to/jquery"], function ($) {
} else if (key[0] === "@") {
attr = key.slice(1);
$tag.data(attr, options[key]);
} else if (key === "class" && $.isArray(options[key])) {
$tag.attr(key, options[key].join(" "));
} else {
$tag.attr(key, options[key]);
}
Expand Down
17 changes: 13 additions & 4 deletions jquery.lego.web.js
Expand Up @@ -23,13 +23,20 @@
$.lego = function (tag) {
var key, $tag, i, childs, attr, options;

// if tag is an object get the key as tag and value as options
if (typeof(tag) === "string") {
return $.lego(legoparser.parse(tag));
} else if ($.isArray(tag)) {
return $.map(tag, function (item) {
return $.lego(item);
});
if (tag.length === 1) {
if (typeof(tag[0]) === "string") {
$.lego({"div": {"$childs": tag}});
} else {
$.lego(tag[0]);
}
} else {
return $.map(tag, function (item) {
return $.lego(item);
});
}
} else {
key = getFirstKey(tag);
options = tag[key];
Expand Down Expand Up @@ -76,6 +83,8 @@
} else if (key[0] === "@") {
attr = key.slice(1);
$tag.data(attr, options[key]);
} else if (key === "class" && $.isArray(options[key])) {
$tag.attr(key, options[key].join(" "));
} else {
$tag.attr(key, options[key]);
}
Expand Down

0 comments on commit 72dbe0c

Please sign in to comment.