mathieuravaux-god_web 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.gitignore +1 -0
  2. data/bin/god_web +0 -54
  3. data/bugs/issue-28789de6ef59a981f26031fdf68030a1474251e8.yaml +18 -0
  4. data/bugs/issue-949b87d1535bd55950daf2ec197a25ce2a0de13f.yaml +18 -0
  5. data/bugs/issue-9579e138eec0aee906895eefa1cc546bd7d54b0d.yaml +18 -0
  6. data/bugs/issue-b13b98759d3cf194cfee1bc00f0245f4b19f6cd2.yaml +18 -0
  7. data/bugs/issue-cf27fa73c85d2b7a389cbdcfe669b9703380667c.yaml +18 -0
  8. data/bugs/project.yaml +16 -0
  9. data/god_web.gemspec +105 -0
  10. data/lib/app.rb +55 -0
  11. data/lib/environment.rb +1 -1
  12. data/lib/god_web.rb +50 -23
  13. data/public/.DS_Store +0 -0
  14. data/public/app.css +26 -0
  15. data/public/icons/databases.png +0 -0
  16. data/public/icons/gear.png +0 -0
  17. data/public/icons/groups.png +0 -0
  18. data/public/icons/key.png +0 -0
  19. data/public/icons/monitor.png +0 -0
  20. data/public/icons/restart.png +0 -0
  21. data/public/icons/ruby.png +0 -0
  22. data/public/icons/server.png +0 -0
  23. data/public/icons/start.png +0 -0
  24. data/public/icons/stop.png +0 -0
  25. data/public/icons/terminal.png +0 -0
  26. data/public/icons/unmonitor.png +0 -0
  27. data/public/icons/unmonitored.png +0 -0
  28. data/public/icons/unmonitored_old.png +0 -0
  29. data/public/icons/up.png +0 -0
  30. data/public/icons/warn.png +0 -0
  31. data/public/icons/wrench.png +0 -0
  32. data/public/iui/iui-logo-touch-icon.png +0 -0
  33. data/public/iui/iui.css +27 -3
  34. data/public/iui/iui.js +418 -291
  35. data/public/iui/iuix.css +1 -1
  36. data/public/iui/iuix.js +1 -1
  37. data/public/iui/redButton.png +0 -0
  38. data/spec/god_web_spec.rb +20 -0
  39. data/spec/spec_helper.rb +11 -0
  40. data/views/status.erb +17 -14
  41. data/views/watch.erb +7 -2
  42. metadata +62 -21
data/public/.DS_Store ADDED
Binary file
data/public/app.css ADDED
@@ -0,0 +1,26 @@
1
+ body > ul > li {
2
+ padding-left: 30px;
3
+ }
4
+ li.up { background: transparent url(../icons/up.png) no-repeat scroll 8px 12px;}
5
+ li.unmonitored { background: transparent url(../icons/unmonitored.png) no-repeat scroll 8px 12px;}
6
+ li.monitor { background: transparent url(../icons/monitor.png) no-repeat scroll 8px 12px;}
7
+ li.start { background: transparent url(../icons/start.png) no-repeat scroll 8px 12px;}
8
+ li.stop { background: transparent url(../icons/stop.png) no-repeat scroll 8px 12px; }
9
+ li.restart { background: transparent url(../icons/restart.png) no-repeat scroll 8px 12px;}
10
+ li.unmonitor { background: transparent url(../icons/unmonitor.png) no-repeat scroll 8px 12px;}
11
+ li.groups { background: transparent url(../icons/groups.png) no-repeat scroll 8px 12px;}
12
+
13
+ .info {
14
+ font-size: 0.8em;
15
+ }
16
+
17
+ .gray { color: #aaa; }
18
+
19
+ .green {
20
+ color: #00aa00;
21
+ font-weight: bold;
22
+ }
23
+ .red {
24
+ color: #aa0000;
25
+ font-weight: bold;
26
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/public/iui/iui.css CHANGED
@@ -1,4 +1,4 @@
1
- /* iui.css (c) 2007 by iUI Project Members, see LICENSE.txt for license */
1
+ /* iui.css (c) 2007-9 by iUI Project Members, see LICENSE.txt for license */
2
2
  body {
3
3
  margin: 0;
4
4
  font-family: Helvetica;
@@ -18,6 +18,9 @@ body > *:not(.toolbar) {
18
18
  top: 45px;
19
19
  width: 100%;
20
20
  min-height: 372px;
21
+ -webkit-transition-duration: 300ms;
22
+ -webkit-transition-property: -webkit-transform;
23
+ -webkit-transform: translateX(0%);
21
24
  }
22
25
 
23
26
  body[orient="landscape"] > *:not(.toolbar) {
@@ -118,6 +121,7 @@ body[orient="landscape"] > .toolbar > h1 {
118
121
  }
119
122
 
120
123
  .whiteButton,
124
+ .redButton,
121
125
  .grayButton {
122
126
  display: block;
123
127
  border-width: 0 12px;
@@ -134,6 +138,12 @@ body[orient="landscape"] > .toolbar > h1 {
134
138
  text-shadow: rgba(255, 255, 255, 0.7) 0 1px 0;
135
139
  }
136
140
 
141
+ .redButton {
142
+ -webkit-border-image: url(redButton.png) 0 12 0 12;
143
+ color:#fff;
144
+ text-shadow: #7a0001 0 -1px 0;
145
+ }
146
+
137
147
  .grayButton {
138
148
  -webkit-border-image: url(grayButton.png) 0 12 0 12;
139
149
  color: #FFFFFF;
@@ -230,7 +240,7 @@ body > .dialog {
230
240
  color: #999999;
231
241
  }
232
242
 
233
- input {
243
+ input:not(input[type|=radio]):not(input[type|=checkbox]) {
234
244
  box-sizing: border-box;
235
245
  -webkit-box-sizing: border-box;
236
246
  width: 100%;
@@ -244,6 +254,7 @@ input {
244
254
 
245
255
  body > .panel {
246
256
  box-sizing: border-box;
257
+ -moz-box-sizing: border-box;
247
258
  -webkit-box-sizing: border-box;
248
259
  padding: 10px;
249
260
  background: #c8c8c8 url(pinstripes.png);
@@ -255,6 +266,7 @@ body > .panel {
255
266
  padding: 0;
256
267
  background: #FFFFFF;
257
268
  -webkit-border-radius: 10px;
269
+ -moz-border-radius: 10px;
258
270
  border: 1px solid #999999;
259
271
  text-align: right;
260
272
  font-size: 16px;
@@ -272,8 +284,9 @@ fieldset > .row:last-child {
272
284
  border-bottom: none !important;
273
285
  }
274
286
 
275
- .row > input {
287
+ .row > input:not(input[type|=radio]):not(input[type|=checkbox]) {
276
288
  box-sizing: border-box;
289
+ -moz-box-sizing: border-box;
277
290
  -webkit-box-sizing: border-box;
278
291
  margin: 0;
279
292
  border: none;
@@ -281,6 +294,11 @@ fieldset > .row:last-child {
281
294
  height: 42px;
282
295
  background: none;
283
296
  }
297
+ .row > input[type|=radio], .row > input[type|=checkbox] {
298
+ margin: 7px 7px 0 0;
299
+ height: 25px;
300
+ width: 25px;
301
+ }
284
302
 
285
303
  .row > label {
286
304
  position: absolute;
@@ -289,6 +307,12 @@ fieldset > .row:last-child {
289
307
  font-weight: bold;
290
308
  }
291
309
 
310
+ .row > span {
311
+ position: absolute;
312
+ padding: 12px 10px 0 110px;
313
+ margin: 0;
314
+ }
315
+
292
316
  .row > .toggle {
293
317
  position: absolute;
294
318
  top: 6px;
data/public/iui/iui.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
- Copyright (c) 2007, iUI Project Members
3
- See LICENSE.txt for licensing terms
2
+ Copyright (c) 2007-9, iUI Project Members
3
+ See LICENSE.txt for licensing terms
4
4
  */
5
5
 
6
6
 
@@ -17,364 +17,491 @@ var hashPrefix = "#_";
17
17
  var pageHistory = [];
18
18
  var newPageCount = 0;
19
19
  var checkTimer;
20
+ var hasOrientationEvent = false;
21
+ var portraitVal = "portrait";
22
+ var landscapeVal = "landscape";
20
23
 
21
24
  // *************************************************************************************************
22
25
 
23
26
  window.iui =
24
27
  {
25
- showPage: function(page, backwards)
26
- {
27
- if (page)
28
- {
29
- if (currentDialog)
30
- {
31
- currentDialog.removeAttribute("selected");
32
- currentDialog = null;
33
- }
34
-
35
- if (hasClass(page, "dialog"))
36
- showDialog(page);
37
- else
38
- {
39
- var fromPage = currentPage;
40
- currentPage = page;
41
-
42
- if (fromPage)
43
- setTimeout(slidePages, 0, fromPage, page, backwards);
44
- else
45
- updatePage(page, fromPage);
46
- }
47
- }
48
- },
49
-
50
- showPageById: function(pageId)
51
- {
52
- var page = $(pageId);
53
- if (page)
54
- {
55
- var index = pageHistory.indexOf(pageId);
56
- var backwards = index != -1;
57
- if (backwards)
58
- pageHistory.splice(index, pageHistory.length);
59
-
60
- iui.showPage(page, backwards);
61
- }
62
- },
63
-
64
- showPageByHref: function(href, args, method, replace, cb)
65
- {
66
- var req = new XMLHttpRequest();
67
- req.onerror = function()
68
- {
69
- if (cb)
70
- cb(false);
71
- };
72
-
73
- req.onreadystatechange = function()
74
- {
75
- if (req.readyState == 4)
76
- {
77
- if (replace)
78
- replaceElementWithSource(replace, req.responseText);
79
- else
80
- {
81
- var frag = document.createElement("div");
82
- frag.innerHTML = req.responseText;
83
- iui.insertPages(frag.childNodes);
84
- }
85
- if (cb)
86
- setTimeout(cb, 1000, true);
87
- }
88
- };
89
-
90
- if (args)
91
- {
92
- req.open(method || "GET", href, true);
93
- req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
94
- req.setRequestHeader("Content-Length", args.length);
95
- req.send(args.join("&"));
96
- }
97
- else
98
- {
99
- req.open(method || "GET", href, true);
100
- req.send(null);
101
- }
102
- },
103
-
104
- insertPages: function(nodes)
105
- {
106
- var targetPage;
107
- for (var i = 0; i < nodes.length; ++i)
108
- {
109
- var child = nodes[i];
110
- if (child.nodeType == 1)
111
- {
112
- if (!child.id)
113
- child.id = "__" + (++newPageCount) + "__";
114
-
115
- var clone = $(child.id);
116
- if (clone)
117
- clone.parentNode.replaceChild(child, clone);
118
- else
119
- document.body.appendChild(child);
120
-
121
- if (child.getAttribute("selected") == "true" || !targetPage)
122
- targetPage = child;
123
-
124
- --i;
125
- }
126
- }
127
-
128
- if (targetPage)
129
- iui.showPage(targetPage);
130
- },
131
-
132
- getSelectedPage: function()
133
- {
134
- for (var child = document.body.firstChild; child; child = child.nextSibling)
135
- {
136
- if (child.nodeType == 1 && child.getAttribute("selected") == "true")
137
- return child;
138
- }
139
- }
28
+ animOn: false, // Experimental slide animation with CSS transition disabled by default
29
+
30
+ showPage: function(page, backwards)
31
+ {
32
+ if (page)
33
+ {
34
+ if (currentDialog)
35
+ {
36
+ currentDialog.removeAttribute("selected");
37
+ currentDialog = null;
38
+ }
39
+
40
+ if (hasClass(page, "dialog"))
41
+ showDialog(page);
42
+ else
43
+ {
44
+ var fromPage = currentPage;
45
+ currentPage = page;
46
+
47
+ if (fromPage)
48
+ setTimeout(slidePages, 0, fromPage, page, backwards);
49
+ else
50
+ updatePage(page, fromPage);
51
+ }
52
+ }
53
+ },
54
+
55
+ showPageById: function(pageId)
56
+ {
57
+ var page = $(pageId);
58
+ if (page)
59
+ {
60
+ var index = pageHistory.indexOf(pageId);
61
+ var backwards = index != -1;
62
+ if (backwards)
63
+ pageHistory.splice(index, pageHistory.length);
64
+
65
+ iui.showPage(page, backwards);
66
+ }
67
+ },
68
+
69
+ showPageByHref: function(href, args, method, replace, cb)
70
+ {
71
+ var req = new XMLHttpRequest();
72
+ req.onerror = function()
73
+ {
74
+ if (cb)
75
+ cb(false);
76
+ };
77
+
78
+ req.onreadystatechange = function()
79
+ {
80
+ if (req.readyState == 4)
81
+ {
82
+ if (replace)
83
+ replaceElementWithSource(replace, req.responseText);
84
+ else
85
+ {
86
+ var frag = document.createElement("div");
87
+ frag.innerHTML = req.responseText;
88
+ iui.insertPages(frag.childNodes);
89
+ }
90
+ if (cb)
91
+ setTimeout(cb, 1000, true);
92
+ }
93
+ };
94
+
95
+ if (args)
96
+ {
97
+ req.open(method || "GET", href, true);
98
+ req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
99
+ req.setRequestHeader("Content-Length", args.length);
100
+ req.send(args.join("&"));
101
+ }
102
+ else
103
+ {
104
+ req.open(method || "GET", href, true);
105
+ req.send(null);
106
+ }
107
+ },
108
+
109
+ insertPages: function(nodes)
110
+ {
111
+ var targetPage;
112
+ for (var i = 0; i < nodes.length; ++i)
113
+ {
114
+ var child = nodes[i];
115
+ if (child.nodeType == 1)
116
+ {
117
+ if (!child.id)
118
+ child.id = "__" + (++newPageCount) + "__";
119
+
120
+ var clone = $(child.id);
121
+ if (clone)
122
+ clone.parentNode.replaceChild(child, clone);
123
+ else
124
+ document.body.appendChild(child);
125
+
126
+ if (child.getAttribute("selected") == "true" || !targetPage)
127
+ targetPage = child;
128
+
129
+ --i;
130
+ }
131
+ }
132
+
133
+ if (targetPage)
134
+ iui.showPage(targetPage);
135
+ },
136
+
137
+ getSelectedPage: function()
138
+ {
139
+ for (var child = document.body.firstChild; child; child = child.nextSibling)
140
+ {
141
+ if (child.nodeType == 1 && child.getAttribute("selected") == "true")
142
+ return child;
143
+ }
144
+ },
145
+ isNativeUrl: function(href)
146
+ {
147
+ for(var i = 0; i < iui.nativeUrlPatterns.length; i++)
148
+ {
149
+ if(href.match(iui.nativeUrlPatterns[i])) return true;
150
+ }
151
+ return false;
152
+ },
153
+ nativeUrlPatterns: [
154
+ new RegExp("^http:\/\/maps.google.com\/maps\?"),
155
+ new RegExp("^mailto:"),
156
+ new RegExp("^tel:"),
157
+ new RegExp("^http:\/\/www.youtube.com\/watch\\?v="),
158
+ new RegExp("^http:\/\/www.youtube.com\/v\/"),
159
+ new RegExp("^javascript:"),
160
+
161
+ ]
140
162
  };
141
163
 
142
164
  // *************************************************************************************************
143
165
 
144
166
  addEventListener("load", function(event)
145
167
  {
146
- var page = iui.getSelectedPage();
147
- if (page)
148
- iui.showPage(page);
168
+ var page = iui.getSelectedPage();
169
+ var locPage = getPageFromLoc();
170
+
171
+ if (page)
172
+ iui.showPage(page);
173
+
174
+ if (locPage && (locPage != page))
175
+ iui.showPage(locPage);
176
+
177
+ setTimeout(preloadImages, 0);
178
+ if (typeof window.onorientationchange == "object")
179
+ {
180
+ window.onorientationchange=orientChangeHandler;
181
+ hasOrientationEvent = true;
182
+ setTimeout(orientChangeHandler, 0);
183
+ }
184
+ setTimeout(checkOrientAndLocation, 0);
185
+ checkTimer = setInterval(checkOrientAndLocation, 300);
186
+ }, false);
149
187
 
150
- setTimeout(preloadImages, 0);
151
- setTimeout(checkOrientAndLocation, 0);
152
- checkTimer = setInterval(checkOrientAndLocation, 300);
188
+ addEventListener("unload", function(event)
189
+ {
190
+ return;
153
191
  }, false);
154
-
192
+
155
193
  addEventListener("click", function(event)
156
194
  {
157
- var link = findParent(event.target, "a");
158
- if (link)
159
- {
160
- function unselect() { link.removeAttribute("selected"); }
161
-
162
- if (link.href && link.hash && link.hash != "#")
163
- {
164
- link.setAttribute("selected", "true");
165
- iui.showPage($(link.hash.substr(1)));
166
- setTimeout(unselect, 500);
167
- }
168
- else if (link == $("backButton"))
169
- history.back();
170
- else if (link.getAttribute("type") == "submit")
171
- submitForm(findParent(link, "form"));
172
- else if (link.getAttribute("type") == "cancel")
173
- cancelDialog(findParent(link, "form"));
174
- else if (link.target == "_replace")
175
- {
176
- link.setAttribute("selected", "progress");
177
- iui.showPageByHref(link.href, null, null, link, unselect);
178
- }
179
- else if (!link.target)
180
- {
181
- link.setAttribute("selected", "progress");
182
- iui.showPageByHref(link.href, null, null, null, unselect);
183
- }
184
- else
185
- return;
186
-
187
- event.preventDefault();
188
- }
195
+ var link = findParent(event.target, "a");
196
+ if (link)
197
+ {
198
+ function unselect() { link.removeAttribute("selected"); }
199
+
200
+ if (link.href && link.hash && link.hash != "#" && !link.target)
201
+ {
202
+ link.setAttribute("selected", "true");
203
+ iui.showPage($(link.hash.substr(1)));
204
+ setTimeout(unselect, 500);
205
+ }
206
+ else if (link == $("backButton"))
207
+ history.back();
208
+ else if (link.getAttribute("type") == "submit")
209
+ submitForm(findParent(link, "form"));
210
+ else if (link.getAttribute("type") == "cancel")
211
+ cancelDialog(findParent(link, "form"));
212
+ else if (link.target == "_replace")
213
+ {
214
+ link.setAttribute("selected", "progress");
215
+ iui.showPageByHref(link.href, null, null, link, unselect);
216
+ }
217
+ else if (iui.isNativeUrl(link.href))
218
+ {
219
+ return;
220
+ }
221
+ else if (link.target == "_webapp")
222
+ {
223
+ location.href = link.href;
224
+ }
225
+ else if (!link.target)
226
+ {
227
+ link.setAttribute("selected", "progress");
228
+ iui.showPageByHref(link.href, null, null, null, unselect);
229
+ }
230
+ else
231
+ return;
232
+
233
+ event.preventDefault();
234
+ }
189
235
  }, true);
190
236
 
191
237
  addEventListener("click", function(event)
192
238
  {
193
- var div = findParent(event.target, "div");
194
- if (div && hasClass(div, "toggle"))
195
- {
196
- div.setAttribute("toggled", div.getAttribute("toggled") != "true");
197
- event.preventDefault();
198
- }
239
+ var div = findParent(event.target, "div");
240
+ if (div && hasClass(div, "toggle"))
241
+ {
242
+ div.setAttribute("toggled", div.getAttribute("toggled") != "true");
243
+ event.preventDefault();
244
+ }
199
245
  }, true);
200
246
 
247
+ function getPageFromLoc()
248
+ {
249
+ var page;
250
+ var result = location.hash.match(/#_([^\?_]+)/);
251
+ if (result)
252
+ page = result[1];
253
+ if (page)
254
+ page = $(page);
255
+ return page;
256
+ }
257
+
258
+ function orientChangeHandler()
259
+ {
260
+ var orientation=window.orientation;
261
+ switch(orientation)
262
+ {
263
+ case 0:
264
+ setOrientation(portraitVal);
265
+ break;
266
+
267
+ case 90:
268
+ case -90:
269
+ setOrientation(landscapeVal);
270
+ break;
271
+ }
272
+ }
273
+
274
+
201
275
  function checkOrientAndLocation()
202
276
  {
203
- if (window.innerWidth != currentWidth)
204
- {
205
- currentWidth = window.innerWidth;
206
- var orient = currentWidth == 320 ? "profile" : "landscape";
207
- document.body.setAttribute("orient", orient);
208
- setTimeout(scrollTo, 100, 0, 1);
209
- }
210
-
211
- if (location.hash != currentHash)
212
- {
213
- var pageId = location.hash.substr(hashPrefix.length)
214
- iui.showPageById(pageId);
215
- }
277
+ if (!hasOrientationEvent)
278
+ {
279
+ if (window.innerWidth != currentWidth)
280
+ {
281
+ currentWidth = window.innerWidth;
282
+ var orient = currentWidth == 320 ? portraitVal : landscapeVal;
283
+ setOrientation(orient);
284
+ }
285
+ }
286
+
287
+ if (location.hash != currentHash)
288
+ {
289
+ var pageId = location.hash.substr(hashPrefix.length);
290
+ iui.showPageById(pageId);
291
+ }
292
+ }
293
+
294
+ function setOrientation(orient)
295
+ {
296
+ document.body.setAttribute("orient", orient);
297
+ setTimeout(scrollTo, 100, 0, 1);
216
298
  }
217
299
 
218
300
  function showDialog(page)
219
301
  {
220
- currentDialog = page;
221
- page.setAttribute("selected", "true");
222
-
223
- if (hasClass(page, "dialog") && !page.target)
224
- showForm(page);
302
+ currentDialog = page;
303
+ page.setAttribute("selected", "true");
304
+
305
+ if (hasClass(page, "dialog") && !page.target)
306
+ showForm(page);
225
307
  }
226
308
 
227
309
  function showForm(form)
228
310
  {
229
- form.onsubmit = function(event)
230
- {
231
- event.preventDefault();
232
- submitForm(form);
233
- };
234
-
235
- form.onclick = function(event)
236
- {
237
- if (event.target == form && hasClass(form, "dialog"))
238
- cancelDialog(form);
239
- };
311
+ form.onsubmit = function(event)
312
+ {
313
+ event.preventDefault();
314
+ submitForm(form);
315
+ };
316
+
317
+ form.onclick = function(event)
318
+ {
319
+ if (event.target == form && hasClass(form, "dialog"))
320
+ cancelDialog(form);
321
+ };
240
322
  }
241
323
 
242
324
  function cancelDialog(form)
243
325
  {
244
- form.removeAttribute("selected");
326
+ form.removeAttribute("selected");
245
327
  }
246
328
 
247
329
  function updatePage(page, fromPage)
248
330
  {
249
- if (!page.id)
250
- page.id = "__" + (++newPageCount) + "__";
251
-
252
- location.href = currentHash = hashPrefix + page.id;
253
- pageHistory.push(page.id);
254
-
255
- var pageTitle = $("pageTitle");
256
- if (page.title)
257
- pageTitle.innerHTML = page.title;
258
-
259
- if (page.localName.toLowerCase() == "form" && !page.target)
260
- showForm(page);
261
-
262
- var backButton = $("backButton");
263
- if (backButton)
264
- {
265
- var prevPage = $(pageHistory[pageHistory.length-2]);
266
- if (prevPage && !page.getAttribute("hideBackButton"))
267
- {
268
- backButton.style.display = "inline";
269
- backButton.innerHTML = prevPage.title ? prevPage.title : "Back";
270
- }
271
- else
272
- backButton.style.display = "none";
273
- }
331
+ if (!page.id)
332
+ page.id = "__" + (++newPageCount) + "__";
333
+
334
+ location.hash = currentHash = hashPrefix + page.id;
335
+ pageHistory.push(page.id);
336
+
337
+ var pageTitle = $("pageTitle");
338
+ if (page.title)
339
+ pageTitle.innerHTML = page.title;
340
+
341
+ if (page.localName.toLowerCase() == "form" && !page.target)
342
+ showForm(page);
343
+
344
+ var backButton = $("backButton");
345
+ if (backButton)
346
+ {
347
+ var prevPage = $(pageHistory[pageHistory.length-2]);
348
+ if (prevPage && !page.getAttribute("hideBackButton"))
349
+ {
350
+ backButton.style.display = "inline";
351
+ backButton.innerHTML = prevPage.title ? prevPage.title : "Back";
352
+ }
353
+ else
354
+ backButton.style.display = "none";
355
+ }
274
356
  }
275
357
 
276
358
  function slidePages(fromPage, toPage, backwards)
277
- {
278
- var axis = (backwards ? fromPage : toPage).getAttribute("axis");
279
- if (axis == "y")
280
- (backwards ? fromPage : toPage).style.top = "100%";
281
- else
282
- toPage.style.left = "100%";
283
-
284
- toPage.setAttribute("selected", "true");
285
- scrollTo(0, 1);
286
- clearInterval(checkTimer);
287
-
288
- var percent = 100;
289
- slide();
290
- var timer = setInterval(slide, slideInterval);
291
-
292
- function slide()
293
- {
294
- percent -= slideSpeed;
295
- if (percent <= 0)
296
- {
297
- percent = 0;
298
- if (!hasClass(toPage, "dialog"))
299
- fromPage.removeAttribute("selected");
300
- clearInterval(timer);
301
- checkTimer = setInterval(checkOrientAndLocation, 300);
302
- setTimeout(updatePage, 0, toPage, fromPage);
303
- }
304
-
305
- if (axis == "y")
306
- {
307
- backwards
308
- ? fromPage.style.top = (100-percent) + "%"
309
- : toPage.style.top = percent + "%";
310
- }
311
- else
312
- {
313
- fromPage.style.left = (backwards ? (100-percent) : (percent-100)) + "%";
314
- toPage.style.left = (backwards ? -percent : percent) + "%";
315
- }
316
- }
359
+ {
360
+ var axis = (backwards ? fromPage : toPage).getAttribute("axis");
361
+
362
+ clearInterval(checkTimer);
363
+
364
+ if (canDoSlideAnim() && axis != 'y')
365
+ {
366
+ slide2(fromPage, toPage, backwards, slideDone);
367
+ }
368
+ else
369
+ {
370
+ slide1(fromPage, toPage, backwards, axis, slideDone);
371
+ }
372
+
373
+ function slideDone()
374
+ {
375
+ if (!hasClass(toPage, "dialog"))
376
+ fromPage.removeAttribute("selected");
377
+ checkTimer = setInterval(checkOrientAndLocation, 300);
378
+ setTimeout(updatePage, 0, toPage, fromPage);
379
+ fromPage.removeEventListener('webkitTransitionEnd', slideDone, false);
380
+ }
381
+ }
382
+
383
+ function canDoSlideAnim()
384
+ {
385
+ return (iui.animOn) && (typeof WebKitCSSMatrix == "object");
386
+ }
387
+
388
+ function slide1(fromPage, toPage, backwards, axis, cb)
389
+ {
390
+ if (axis == "y")
391
+ (backwards ? fromPage : toPage).style.top = "100%";
392
+ else
393
+ toPage.style.left = "100%";
394
+
395
+ scrollTo(0, 1);
396
+ toPage.setAttribute("selected", "true");
397
+ var percent = 100;
398
+ slide();
399
+ var timer = setInterval(slide, slideInterval);
400
+
401
+ function slide()
402
+ {
403
+ percent -= slideSpeed;
404
+ if (percent <= 0)
405
+ {
406
+ percent = 0;
407
+ clearInterval(timer);
408
+ cb();
409
+ }
410
+
411
+ if (axis == "y")
412
+ {
413
+ backwards
414
+ ? fromPage.style.top = (100-percent) + "%"
415
+ : toPage.style.top = percent + "%";
416
+ }
417
+ else
418
+ {
419
+ fromPage.style.left = (backwards ? (100-percent) : (percent-100)) + "%";
420
+ toPage.style.left = (backwards ? -percent : percent) + "%";
421
+ }
422
+ }
423
+ }
424
+
425
+
426
+ function slide2(fromPage, toPage, backwards, cb)
427
+ {
428
+ toPage.style.webkitTransitionDuration = '0ms'; // Turn off transitions to set toPage start offset
429
+ // fromStart is always 0% and toEnd is always 0%
430
+ // iPhone won't take % width on toPage
431
+ var toStart = 'translateX(' + (backwards ? '-' : '') + window.innerWidth + 'px)';
432
+ var fromEnd = 'translateX(' + (backwards ? '100%' : '-100%') + ')';
433
+ toPage.style.webkitTransform = toStart;
434
+ toPage.setAttribute("selected", "true");
435
+ toPage.style.webkitTransitionDuration = ''; // Turn transitions back on
436
+ function startTrans()
437
+ {
438
+ fromPage.style.webkitTransform = fromEnd;
439
+ toPage.style.webkitTransform = 'translateX(0%)'; //toEnd
440
+ }
441
+ fromPage.addEventListener('webkitTransitionEnd', cb, false);
442
+ setTimeout(startTrans, 0);
317
443
  }
318
444
 
319
445
  function preloadImages()
320
446
  {
321
- var preloader = document.createElement("div");
322
- preloader.id = "preloader";
323
- document.body.appendChild(preloader);
447
+ var preloader = document.createElement("div");
448
+ preloader.id = "preloader";
449
+ document.body.appendChild(preloader);
324
450
  }
325
451
 
326
452
  function submitForm(form)
327
453
  {
328
- iui.showPageByHref(form.action || "POST", encodeForm(form), form.method);
454
+ iui.showPageByHref(form.action || "POST", encodeForm(form), form.method);
329
455
  }
330
456
 
331
457
  function encodeForm(form)
332
458
  {
333
- function encode(inputs)
334
- {
335
- for (var i = 0; i < inputs.length; ++i)
336
- {
337
- if (inputs[i].name)
338
- args.push(inputs[i].name + "=" + escape(inputs[i].value));
339
- }
340
- }
341
-
342
- var args = [];
343
- encode(form.getElementsByTagName("input"));
344
- encode(form.getElementsByTagName("select"));
345
- return args;
459
+ function encode(inputs)
460
+ {
461
+ for (var i = 0; i < inputs.length; ++i)
462
+ {
463
+ if (inputs[i].name)
464
+ args.push(inputs[i].name + "=" + escape(inputs[i].value));
465
+ }
466
+ }
467
+
468
+ var args = [];
469
+ encode(form.getElementsByTagName("input"));
470
+ encode(form.getElementsByTagName("textarea"));
471
+ encode(form.getElementsByTagName("select"));
472
+ return args;
346
473
  }
347
474
 
348
475
  function findParent(node, localName)
349
476
  {
350
- while (node && (node.nodeType != 1 || node.localName.toLowerCase() != localName))
351
- node = node.parentNode;
352
- return node;
477
+ while (node && (node.nodeType != 1 || node.localName.toLowerCase() != localName))
478
+ node = node.parentNode;
479
+ return node;
353
480
  }
354
481
 
355
482
  function hasClass(self, name)
356
483
  {
357
- var re = new RegExp("(^|\\s)"+name+"($|\\s)");
358
- return re.exec(self.getAttribute("class")) != null;
484
+ var re = new RegExp("(^|\\s)"+name+"($|\\s)");
485
+ return re.exec(self.getAttribute("class")) != null;
359
486
  }
360
487
 
361
488
  function replaceElementWithSource(replace, source)
362
489
  {
363
- var page = replace.parentNode;
364
- var parent = replace;
365
- while (page.parentNode != document.body)
366
- {
367
- page = page.parentNode;
368
- parent = parent.parentNode;
369
- }
490
+ var page = replace.parentNode;
491
+ var parent = replace;
492
+ while (page.parentNode != document.body)
493
+ {
494
+ page = page.parentNode;
495
+ parent = parent.parentNode;
496
+ }
370
497
 
371
- var frag = document.createElement(parent.localName);
372
- frag.innerHTML = source;
498
+ var frag = document.createElement(parent.localName);
499
+ frag.innerHTML = source;
373
500
 
374
- page.removeChild(parent);
501
+ page.removeChild(parent);
375
502
 
376
- while (frag.firstChild)
377
- page.appendChild(frag.firstChild);
503
+ while (frag.firstChild)
504
+ page.appendChild(frag.firstChild);
378
505
  }
379
506
 
380
507
  function $(id) { return document.getElementById(id); }