-
Notifications
You must be signed in to change notification settings - Fork 0
/
widget.js
34 lines (31 loc) · 1.09 KB
/
widget.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
33
34
(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-app-machina/widget"] = factory.apply(root, modules.map(function (m) {
return root[m];
}));
}
})(["./create", "mu-jquery-widget/widget"], this, function (create, widget) {
return create(widget.concat(), function ($element, ns, opt) {
var me = this
var $ = $element.constructor;
var ops = me.constructor.fsm.slice();
var fsm = opt.fsm;
["handle", "transition", "clearQueue", "deferAndTransition", "compositeState"].forEach(function (method) {
me[method] = $.proxy(fsm[method], fsm);
});
me.on("initialize", function() {
ops = $.map(ops, function (op) {
return fsm.on(op.name, $.proxy(op.handler, me));
});
});
me.on("finalize", function() {
ops = $.map(ops, function (op) {
return op.off();
});
});
});
});