-
Notifications
You must be signed in to change notification settings - Fork 0
/
WPWaveView.j
90 lines (69 loc) · 2.02 KB
/
WPWaveView.j
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
@import <Foundation/CPObject.j>
@implementation WPWaveView : CPView
{
DOMElement wp_DOMWaveElement;
Object _wavePanel;
CPString waveID @accessors;
}
- (id)init
{
if (self = [super init])
{
}
return self;
}
-(void) _buildDOM
{
wp_DOMWaveElement = document.createElement("div");
wp_DOMWaveElement.id = "WPWaveView" + [self UID];
var style = m_DOMMapElement.style,
bounds = [self bounds],
width = CGRectGetWidth(bounds),
height = CGRectGetHeight(bounds);
style.overflow = "hidden";
style.position = "absolute";
style.visibility = "visible";
style.zIndex = 0;
style.left = -width + "px";
style.top = -height + "px";
style.width = width + "px";
style.height = height + "px";
document.body.appendChild(wp_DOMWaveElement);
var embedOptions = {
target: wp_DOMWaveElement,
rootUrl: 'http://wave.google.com/a/wavesandbox.com/'
}
_wavePanel = new google.wave.WavePanel(embedOptions);
_wavePanel.loadWave("googlewave.com"+waveID);
}
@end
function prepareGoogleAPI()
{
var DOMScriptElement = document.createElement("script");
DOMScriptElement.src = "http://www.google.com/jsapi ?callback=_WPWaveViewGoogleAjaxLoaderLoaded";
DOMScriptElement.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(DOMScriptElement);
}
function _WPWaveViewGoogleAjaxLoaderLoaded()
{
google.load("wave", 1);
[self _buildDOM];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
@implementation CPWaveView (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
if (self)
{
[self setWaveID:[aCoder decodeObjectForKey:"WAVEID"]];
[self _buildDOM];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeObject:[self _waveID] forKey:"WAVEID"];
}
@end