-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathAddress.js
170 lines (150 loc) · 5.07 KB
/
Address.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
var Address = Address || ( function () {
var _public = {},
$root, $block, $indexCon,
_mode = 0,//0-index,1-sub,2-about
_cursor = 0,//0-normal, 1-move, 2-nwse-resize, 3-slide
_isCancel = 0, _curClass, _isAble = true;
function init() {
$block = document.getElementById('block');
$root = document.getElementById('root');
$indexCon = document.createElement('div');
$indexCon.id = 'index-container';
if (CMDetect.VENDOR != 'webkit' && CMDetect.VENDOR != 'Moz' && CMDetect.VENDOR != 'ms') {
CMUtiles.removeDom($block);
$root.className = 'admin';
$root.innerHTML = '<h1>Oops!</h1><div class="message">Material Interaction was created with HTML5 and CSS3.<br>It\'s a Chrome experiment and you can see perfectly on Chrome browser.<br>Please use <a href="http://www.google.com/chrome" target="_blank">Google Chrome browser</a>.</div>';
return;
}
StageController.init({minw:320});
Index.init($root, $indexCon);
About.init($root);
Sub.init($root);
Close.init($root);
if (CMDetect.isTouch) {
addListener(window.document, 'touchstart', touchStart);
addListener(window.document, 'touchmove', touchMove);
addListener(window.document, 'touchend', touchEnd);
}
if (CMDetect.isMouse) {
addListener(window.document, 'mousedown', onDown);
addListener(window.document, 'mousemove', onMove);
addListener(window.document, 'mouseup', onUp);
}
}
function showAbout() {
unable();
_mode = 2;
About.show($indexCon);
TweenLite.delayedCall(1.9, endShowAbout);
}
function endShowAbout() {
About.endShow();
able();
}
function hideAbout() {
unable();
About.hide();
TweenLite.delayedCall(1.9, endHideAbout);
}
function endHideAbout() {
$root.appendChild($indexCon);
About.endHide();
able();
}
function goSub(no) {
_mode = 1;
_isCancel = 0;
unable();
About.hidePage();
Index.goSub(no);
}
function goClose() {
unable();
_isCancel = 0;
if (_mode == 2) {
hideAbout();
} else {
About.showPage(1.2);
Sub.hide();
_curClass = null;
_mode = 0;
setCursor(0);
}
}
function setCursor(cursor) {
if (_cursor == cursor) return;
_cursor = cursor;
switch (_cursor) {
case 0:
$root.className = 'c-normal';
break;
case 1:
$root.className = 'c-move';
break;
case 2:
$root.className = 'c-resize';
break;
case 3:
$root.className = 'c-slide';
break;
}
}
function addCancel() {
_isCancel = 1;
}
function removeCancel() {
_isCancel = 0;
}
function addEvent(obj) {
_curClass = obj;
}
function removeEvent() {
_curClass = null;
}
function onDown(e) {
if (_isCancel) Sub.cancelGuide();
if (_curClass) _curClass.downFn(e.pageX, e.pageY);
}
function onMove(e) {
if (_curClass) {
_curClass.moveFn(e.pageX, e.pageY);
_curClass.checkMouse(e.pageX, e.pageY);
}
}
function onUp(e) {
if (_curClass) _curClass.upFn();
}
function touchStart(e) {
if (_isCancel) Sub.cancelGuide();
var touch = e.touches[0];
if (_curClass) _curClass.downFn(touch.pageX, touch.pageY);
}
function touchMove(e) {
e.preventDefault();
var touch = e.touches[0];
if (_curClass) _curClass.moveFn(touch.pageX, touch.pageY);
}
function touchEnd(e) {
if (_curClass) _curClass.upFn();
}
function able() {
_isAble = true;
$block.style.display = 'none';
}
function unable() {
_isAble = false;
$block.style.display = 'block';
}
_public.init = init;
_public.able = able;
_public.unable = unable;
_public.goSub = goSub;
_public.goClose = goClose;
_public.addEvent = addEvent;
_public.removeEvent = removeEvent;
_public.showAbout = showAbout;
_public.setCursor = setCursor;
_public.addCancel = addCancel;
_public.removeCancel = removeCancel;
return _public;
} )();