This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connectr.js
89 lines (70 loc) · 2.89 KB
/
connectr.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
goog.require('goog.dom');
goog.require('goog.style');
goog.require('goog.events');
goog.require('thetr.connectr.ui.sms.Main');
goog.require('thetr.connectr.dataLoader');
goog.provide('thetr.connectr.Base');
thetr.connectr.load = function() {
var base = new thetr.connectr.Base();
base.init();
thetr.base = base;
};
thetr.connectr.Base = function() {
this.smsUI = null;
};
thetr.connectr.Base.DATA_LOADER = null;
thetr.connectr.Base.prototype.init = function() {
this.mainElem = goog.dom.createDom('div');
goog.style.setSize(this.mainElem, 320, 15);
// this.mainElem.style.overflow = 'hidden';
goog.events.listen(document.body, 'touchstart', this.handleTouchStart, undefined, this);
goog.events.listen(document.body, 'touchmove', this.handleTouchMove, undefined, this);
window.scrollTo(0,1);
var refreshBtn = goog.dom.createDom('div');
this.refreshButton = refreshBtn;
goog.style.setSize(refreshBtn, 100, 20);
goog.dom.setTextContent(refreshBtn, 'Refresh');
refreshBtn.style.backgroundColor = 'green';
goog.events.listen(refreshBtn, 'click', this.handleRefreshBtnClick, undefined, this);
goog.dom.appendChild(this.mainElem, refreshBtn);
goog.dom.appendChild(document.body, this.mainElem);
this.contentElem = goog.dom.createDom('div');
goog.style.setSize(this.contentElem, 320, 465);
this.contentElem.style.overflow = 'hidden';
this.contentElem.style.clear = 'both';
goog.dom.appendChild(document.body, this.contentElem);
thetr.connectr.Base.DATA_LOADER = new thetr.connectr.dataLoader();
this.smsUI = new thetr.connectr.ui.sms.Main(this);
goog.dom.appendChild(this.contentElem, this.smsUI.getRootNode());
setTimeout(function() {
thetr.connectr.Base.DATA_LOADER.updateRecentSMS();
}, 100);
};
thetr.connectr.Base.prototype.showRefreshButton = function(show) {
// goog.style.showElement(this.refreshButton, show);
if (show) {
goog.dom.removeChildren(this.mainElem);
goog.dom.appendChild(this.mainElem, this.refreshButton);
} else {
goog.dom.removeChildren(this.mainElem);
}
};
thetr.connectr.Base.prototype.setTopBar = function(content) {
this.showRefreshButton(false);
goog.dom.appendChild(this.mainElem, content);
};
thetr.connectr.Base.prototype.handleRefreshBtnClick = function(e) {
thetr.connectr.Base.DATA_LOADER.updateRecentSMS();
};
thetr.connectr.Base.prototype.handleTouchStart = function(e) {
this.touchStartY = e.getBrowserEvent().targetTouches[0].pageY;
};
thetr.connectr.Base.prototype.handleTouchMove = function(e) {
e.preventDefault();
var curY = e.getBrowserEvent().targetTouches[0].pageY;
this.contentElem.scrollTop = this.contentElem.scrollTop - (curY - this.touchStartY);
this.touchStartY = curY;
};
thetr.connectr.Base.prototype.scrollTo = function(pos) {
this.contentElem.scrollTop = pos;
};