-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
70 lines (62 loc) · 1.9 KB
/
main.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
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
import React from 'react';
import {render, hydrate} from 'react-dom';
import Card from './src/js/card.jsx';
window.ProtoGraph = window.ProtoGraph || {};
window.ProtoGraph.Card = window.ProtoGraph.Card || {};
ProtoGraph.Card.toCoverImage = function () {
this.cardType = 'toCoverImage';
}
ProtoGraph.Card.toCoverImage.prototype.init = function (options) {
this.options = options;
}
ProtoGraph.Card.toCoverImage.prototype.renderSixteenCol= function (data) {
this.mode = 'col16';
this.render();
}
ProtoGraph.Card.toCoverImage.prototype.renderSevenCol= function (data) {
this.mode = 'col7';
this.render();
}
ProtoGraph.Card.toCoverImage.prototype.renderFourCol= function (data) {
this.mode = 'col4';
this.render();
}
ProtoGraph.Card.toCoverImage.prototype.renderThreeCol= function (data) {
this.mode = 'col3';
this.render();
}
ProtoGraph.Card.toCoverImage.prototype.renderTwoCol= function (data) {
this.mode = 'col2';
this.render();
}
ProtoGraph.Card.toCoverImage.prototype.getData = function (data) {
return this.containerInstance.exportData();
}
ProtoGraph.Card.toCoverImage.prototype.render = function () {
if (this.options.isFromSSR){
hydrate(
<Card
selector={this.options.selector}
dataURL={this.options.data_url}
siteConfigs={this.options.site_configs}
// dataJSON={this.options.initialState.dataJSON}
mode={this.options.mode}
renderingSSR={true}
/>,
this.options.selector);
} else {
render(
<Card
dataURL={this.options.data_url}
selector={this.options.selector}
domain={this.options.domain}
siteConfigURL={this.options.site_config_url}
mode={this.mode}
siteConfigs={this.options.site_configs}
clickCallback={this.options.onClickCallback}
ref={(e) => {
this.containerInstance = this.containerInstance || e;
}} />,
this.options.selector);
}
}