-
Notifications
You must be signed in to change notification settings - Fork 0
/
book.js
32 lines (29 loc) · 1.03 KB
/
book.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(function (modules, factory) {
var root = this;
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-widget-cyoa/examples/book"] = factory.apply(root, modules.map(function (m) {
return root[m.replace(/^\.{2}/, "mu-jquery-widget-cyoa")];
}));
}
})(["mu-jquery-widget/widget", "../walk"], function (widget, walk) {
function create($, json) {
return $("<" + json["@component"] + ">", { "mu-widget": "mu-jquery-widget-cyoa/widget" });
}
return widget.extend({
"on/initialize": function () {
var me = this;
var $ = me.$;
return $.ajax("book.json")
.catch(function (data, textStatus, errorThrown) {
throw new Error("data.json [" + textStatus + "] " + errorThrown);
})
.then(function (json) {
return me.$element.append(walk($, me.json = json, create)).weave();
});
}
})
});