Skip to content

Commit

Permalink
fix: UMD fix and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkaron committed Oct 12, 2016
1 parent 2e3ca0b commit 7d440ac
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
6 changes: 3 additions & 3 deletions create.js
@@ -1,14 +1,14 @@
(function(modules, root, factory) {
(function (modules, root, factory) {
if (typeof define === "function" && define.amd) {
define(modules, factory);
} else if (typeof module === "object" && module.exports) {
module.exports = factory.apply(root, modules.map(require));
} else {
root["mu-jquery-loom/create"] = factory.apply(root, modules.map(function(m) {
root["mu-jquery-loom/create"] = factory.apply(root, modules.map(function (m) {
return root[m];
}));
}
})([], this, function() {
})([], this, function () {
var bind = Function.prototype.bind;

return function (c, args) {
Expand Down
18 changes: 9 additions & 9 deletions jquery.crank.js
@@ -1,25 +1,25 @@
(function(modules, root, factory) {
(function (modules, root, factory) {
if (typeof define === "function" && define.amd) {
define(modules, factory);
} else if (typeof module === "object" && module.exports) {
module.exports = factory.apply(root, modules.map(require));
} else {
root["mu-jquery-loom/jquery.crank"] = factory.apply(root, modules.map(function(m) {
return {
root["mu-jquery-loom/jquery.crank"] = factory.apply(root, modules.map(function (m) {
return this[m] || root[m];
}, {
"jquery": root.jQuery
}[m] || root[m];
}));
}));
}
})([
"jquery",
"mu-jquery-crank/jquery.crank"
], this, function($, crank) {
], this, function ($, crank) {
var slice = Array.prototype.slice;
var re = /\s+/;

return function (attr) {
return crank.apply(this, [function($element) {
return ($element.attr(attr) || "").split(re);
}].concat(slice.call(arguments, 1)));
return crank.apply(this, [function ($element) {
return ($element.attr(attr) || "").split(re);
}].concat(slice.call(arguments, 1)));
}
});
20 changes: 10 additions & 10 deletions jquery.loom.js
@@ -1,41 +1,41 @@
(function(modules, root, factory) {
(function (modules, root, factory) {
if (typeof define === "function" && define.amd) {
define(modules, factory);
} else if (typeof module === "object" && module.exports) {
module.exports = factory.apply(root, modules.map(require));
} else {
root["mu-jquery-loom/jquery.loom"] = factory.apply(root, modules.map(function(m) {
return {
root["mu-jquery-loom/jquery.loom"] = factory.apply(root, modules.map(function (m) {
return this[m] || root[m.replace(/^\./, "mu-jquery-loom")];
}, {
"jquery": root.jQuery
}[m] || root[m.replace(/^\./, "mu-jquery-loom")];
}));
}));
}
})([
"jquery",
"./jquery.crank",
"./jquery.twist",
"./jquery.weave"
], this, function($, crank, twist, weave) {
], this, function ($, crank, twist, weave) {
var slice = Array.prototype.slice;

function find(selector) {
return this.find(selector).addBack(selector);
}

return function(selector) {
return function (selector) {
var args = slice.call(arguments, 1);
var a = args.slice(0, 1);

$.extend(this.constructor.fn, {
"crank": function() {
"crank": function () {
return crank.apply(find.call(this, selector), a.concat(slice.call(arguments)));
},

"twist": function() {
"twist": function () {
return twist.apply(find.call(this, selector), args.concat(slice.call(arguments)));
},

"weave": function() {
"weave": function () {
return weave.apply(find.call(this, selector), args.concat(slice.call(arguments)));
}
});
Expand Down
24 changes: 12 additions & 12 deletions jquery.twist.js
@@ -1,20 +1,20 @@
(function(modules, root, factory) {
(function (modules, root, factory) {
if (typeof define === "function" && define.amd) {
define(modules, factory);
} else if (typeof module === "object" && module.exports) {
module.exports = factory.apply(root, modules.map(require));
} else {
root["mu-jquery-loom/jquery.twist"] = factory.apply(root, modules.map(function(m) {
return {
root["mu-jquery-loom/jquery.twist"] = factory.apply(root, modules.map(function (m) {
return this[m] || root[m.replace(/^\./, "mu-jquery-loom")];
}, {
"jquery": root.jQuery
}[m = m.replace(/^\./, "mu-jquery-loom")] || root[m];
}));
}));
}
})([
"jquery",
"mu-jquery-wire/jquery.wire",
"./create"
], this, function($, wire, create) {
], this, function ($, wire, create) {
var slice = Array.prototype.slice;
var re_space = /\s+/;
var re_clean = /@\d+$/;
Expand All @@ -23,28 +23,28 @@
return !re_clean.test(value);
}

return function(attr, callback) {
return function (attr, callback) {
var args = slice.call(arguments, 2);
var count = 0;
var _create = create;
var _callback = callback;

if(!$.isFunction(callback)) {
if (!$.isFunction(callback)) {
_create = callback.create || _create;
_callback = callback.callback;
}

return wire.call(this,
function($element) {
function ($element) {
return ($element.attr(attr) || "").split(re_space).filter(clean);
},
function($element, index, module) {
function ($element, index, module) {
var self = this;

return $.when(_callback.call(self, module, index)).then(function(result) {
return $.when(_callback.call(self, module, index)).then(function (result) {
result = _create.call(self, result, [$element, module = module + "@" + ++count].concat(args));

$element.attr(attr, function(i, value) {
$element.attr(attr, function (i, value) {
value = value.split(re_space);
value[index] = module;
return value.join(" ");
Expand Down
16 changes: 8 additions & 8 deletions jquery.weave.js
@@ -1,20 +1,20 @@
(function(modules, root, factory) {
(function (modules, root, factory) {
if (typeof define === "function" && define.amd) {
define(modules, factory);
} else if (typeof module === "object" && module.exports) {
module.exports = factory.apply(root, modules.map(require));
} else {
root["mu-jquery-loom/jquery.weave"] = factory.apply(root, modules.map(function(m) {
return {
root["mu-jquery-loom/jquery.weave"] = factory.apply(root, modules.map(function (m) {
return this[m] || root[m.replace(/^\./, "mu-jquery-loom")];
}, {
"jquery": root.jQuery
}[m] || root[m.replace(/^\./, "mu-jquery-loom")];
}));
}));
}
})([
"jquery",
"./jquery.twist",
"mu-jquery-crank/jquery.crank"
], this, function($, twist, crank) {
], this, function ($, twist, crank) {
var slice = Array.prototype.slice;

function collect() {
Expand All @@ -26,7 +26,7 @@
}

function initialize(widgets, index) {
return widgets && crank.call(widgets[0].$element, $.map(widgets, ns), "initialize").then(function() {
return widgets && crank.call(widgets[0].$element, $.map(widgets, ns), "initialize").then(function () {
return widgets;
});
}
Expand All @@ -35,7 +35,7 @@
return $.when.apply(null, $.map(result, initialize)).then(collect);
}

return function() {
return function () {
return twist.apply(this, slice.call(arguments)).then(weave);
}
});

0 comments on commit 7d440ac

Please sign in to comment.