-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathreact.nanoislands.js
More file actions
71 lines (55 loc) · 1.77 KB
/
react.nanoislands.js
File metadata and controls
71 lines (55 loc) · 1.77 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* borschik:include:node_modules/yate/lib/runtime.js */
/* borschik:include:nanoislands.js */
/* borschik:include:externals.yate.js */
/* borschik:include:react.nanoislands.yate.js */
(function() {
"use strict";
function ni(type, options) {
return yr.run("react-nanoislands", options, type);
}
var Island = React.createClass({
displayName: "Island",
componentDidMount: function() {
var node = this.getDOMNode();
var block;
var type = this.props.type;
var handlers = this.props.on;
nb.init(node);
if (node.firstChild) {
block = nb.block(node.firstChild);
}
if (block && handlers) {
Object.keys(handlers).forEach(function(key) {
block.on(key, handlers[key]);
});
}
this.node = node;
this.block = block;
},
componentWillUnmount: function() {
if (this.block) {
this.block.destroy();
delete this.node;
delete this.block;
}
},
render: function() {
var className = "island";
if (this.props.className) {
className += " " + this.props.className;
}
return (
React.createElement("div", {
className: className,
style: {display: "inline-block"},
dangerouslySetInnerHTML: {__html: ni(this.props.type, this.props.options)}
})
);
}
});
nb.Block.prototype.getYateModuleName = function() {
return 'react-nanoislands';
};
window.ni = ni;
window.Island = Island;
})();