jqmobi-rails 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +8 -0
  3. data/LICENSE +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +68 -0
  6. data/jqmobi-rails.gemspec +17 -0
  7. data/lib/jqmobi/rails/engine.rb +6 -0
  8. data/lib/jqmobi/rails/version.rb +7 -0
  9. data/lib/jqmobi/rails.rb +7 -0
  10. data/lib/jqmobi-rails.rb +1 -0
  11. data/vendor/assets/javascripts/jq.mobi.js +1894 -0
  12. data/vendor/assets/javascripts/jq.mobi_ujs.js +393 -0
  13. data/vendor/assets/javascripts/jq.ui.js +3396 -0
  14. data/vendor/assets/javascripts/plugins/jq.actionsheet.js +99 -0
  15. data/vendor/assets/javascripts/plugins/jq.alphatable.js +136 -0
  16. data/vendor/assets/javascripts/plugins/jq.carousel.js +415 -0
  17. data/vendor/assets/javascripts/plugins/jq.css3animate.js +155 -0
  18. data/vendor/assets/javascripts/plugins/jq.drawer.js +224 -0
  19. data/vendor/assets/javascripts/plugins/jq.fx.js +110 -0
  20. data/vendor/assets/javascripts/plugins/jq.passwordBox.js +45 -0
  21. data/vendor/assets/javascripts/plugins/jq.popup.js +201 -0
  22. data/vendor/assets/javascripts/plugins/jq.scroller.js +540 -0
  23. data/vendor/assets/javascripts/plugins/jq.selectBox.js +315 -0
  24. data/vendor/assets/javascripts/plugins/jq.shake.js +39 -0
  25. data/vendor/assets/javascripts/plugins/jq.social.js +113 -0
  26. data/vendor/assets/javascripts/plugins/jq.swipe.js +121 -0
  27. data/vendor/assets/javascripts/plugins/jq.template.js +26 -0
  28. data/vendor/assets/javascripts/plugins/jq.web.min.js +66 -0
  29. data/vendor/assets/stylesheets/plugins/jq.actionsheet.css +57 -0
  30. data/vendor/assets/stylesheets/plugins/jq.popup.css +73 -0
  31. data/vendor/assets/stylesheets/plugins/jq.scroller.css +10 -0
  32. data/vendor/assets/stylesheets/plugins/jq.selectBox.css +35 -0
  33. metadata +77 -0
@@ -0,0 +1,3396 @@
1
+ /**
2
+ * jq.web.css3Animate - css3 animate class for html5 mobile apps
3
+ * @copyright 2011 - AppMobi
4
+ */ (function ($) {
5
+ $.fn["css3Animate"] = function (opts) {
6
+ var tmp;
7
+ for (var i = 0; i < this.length; i++) {
8
+ tmp = new css3Animate(this[i], opts);
9
+ }
10
+ return this.length == 1 ? tmp : this;
11
+ };
12
+
13
+ $["css3AnimateQueue"] = function () {
14
+ return new css3Animate.queue();
15
+ }
16
+ var css3Animate = (function () {
17
+
18
+ if (!window.WebKitCSSMatrix) return;
19
+ var translateOpen = 'm11' in new WebKitCSSMatrix() ? "3d(" : "(";
20
+ var translateClose = 'm11' in new WebKitCSSMatrix() ? ",0)" : ")";
21
+
22
+ var css3Animate = function (elID, options) {
23
+
24
+ if (typeof elID == "string" || elID instanceof String) {
25
+ this.el = document.getElementById(elID);
26
+ } else {
27
+ this.el = elID;
28
+ }
29
+ if (!(this instanceof css3Animate)) {
30
+ return new css3Animate(elID, options);
31
+ }
32
+ if (!this.el) return;
33
+ var that = this;
34
+ if (!options) {
35
+ alert("Please provide configuration options for animation of " + elID);
36
+ return;
37
+ }
38
+
39
+ if(options["time"]===undefined) options["time"]=0;
40
+
41
+ if (options["callback"]) {
42
+ this.callback = options["callback"];
43
+ this.moving = true;
44
+ if(options["time"]!=0){
45
+ this.timeout = window.setTimeout(function () {
46
+ if (that.moving == true && that.callback && typeof (that.callback == "function")) {
47
+ that.moving = false;
48
+ that.callback();
49
+ delete this.callback;
50
+ }
51
+ }, numOnly(options["time"]) + 50);
52
+ }
53
+ } else {
54
+ this.moving = false;
55
+ }
56
+
57
+
58
+ if (!options["y"]) options["y"] = 0;
59
+ if (!options["x"]) options["x"] = 0;
60
+ if (options["previous"]) {
61
+ options.y += numOnly(new WebKitCSSMatrix(
62
+ window.getComputedStyle(this.el).webkitTransform).f);
63
+ options.x += numOnly(new WebKitCSSMatrix(
64
+ window.getComputedStyle(this.el).webkitTransform).e);
65
+ }
66
+ if (!options["origin"]) options.origin = "0% 0%";
67
+
68
+ if (!options["scale"]) options.scale = "1";
69
+
70
+ if (!options["rotateY"]) options.rotateY = "0";
71
+ if (!options["rotateX"]) options.rotateX = "0";
72
+ if (!options["skewY"]) options.skewY = "0";
73
+ if (!options["skewX"]) options.skewX = "0";
74
+
75
+ if (!options["timingFunction"]) options["timingFunction"] = "linear";
76
+
77
+ //check for percent or numbers
78
+ if (typeof (options.x) == "number" || (options.x.indexOf("%") == -1 && options.x.toLowerCase().indexOf("px") == -1 && options.x.toLowerCase().indexOf("deg") == -1)) options.x = parseInt(options.x) + "px";
79
+ if (typeof (options.y) == "number" || (options.y.indexOf("%") == -1 && options.y.toLowerCase().indexOf("px") == -1 && options.y.toLowerCase().indexOf("deg") == -1)) options.y = parseInt(options.y) + "px";
80
+
81
+ this.el.style.webkitTransform = "translate" + translateOpen + (options.x) + "," + (options.y) + translateClose + " scale(" + parseFloat(options.scale) + ") rotate(" + options.rotateX + ") rotateY(" + options.rotateY + ") skew(" + options.skewX + "," + options.skewY + ")";
82
+ this.el.style.webkitBackfaceVisiblity = "hidden";
83
+ var properties = "-webkit-transform";
84
+ if (options["opacity"]!==undefined) {
85
+ this.el.style.opacity = options["opacity"];
86
+ properties+=", opacity";
87
+ }
88
+ if (options["width"]) {
89
+ this.el.style.width = options["width"];
90
+ properties = "all";
91
+ }
92
+ if (options["height"]) {
93
+ this.el.style.height = options["height"];
94
+ properties = "all";
95
+ }
96
+ this.el.style.webkitTransitionProperty = properties;
97
+ if((""+options["time"]).indexOf("s")==-1) var time = options["time"]+"ms";
98
+ else var time = options["time"];
99
+ this.el.style.webkitTransitionDuration = time;
100
+ this.el.style.webkitTransitionTimingFunction = options["timingFunction"];
101
+ this.el.style.webkitTransformOrigin = options.origin;
102
+ if(options["time"]==0 && options["callback"]){
103
+ setTimeout(function(){that.finishAnimation();},0);
104
+ } else {
105
+ this.el.addEventListener("webkitTransitionEnd", that.finishAnimation, false);
106
+ }
107
+ };
108
+
109
+
110
+ css3Animate.prototype = {
111
+ finishAnimation: function (event) {
112
+ if(event) event.preventDefault();
113
+ var that = this;
114
+ if (!this.moving) return;
115
+
116
+ this.moving = false;
117
+ this.el.removeEventListener("webkitTransitionEnd", that.finishAnimation, false);
118
+ if (this.callback && typeof (this.callback == "function")) {
119
+ if (this.timeout) window.clearTimeout(this.timeout);
120
+ this.callback();
121
+ delete this.callback;
122
+ }
123
+ }
124
+ }
125
+ return css3Animate;
126
+ })();
127
+ css3Animate.queue = function () {
128
+ return {
129
+ elements: [],
130
+ push: function (el) {
131
+ this.elements.push(el);
132
+ },
133
+ pop: function () {
134
+ return this.elements.pop();
135
+ },
136
+ run: function () {
137
+ var that = this;
138
+ if (this.elements.length == 0) return;
139
+ if (typeof (this.elements[0]) == "function") {
140
+ var func = this.shift();
141
+ func();
142
+ }
143
+ if (this.elements.length == 0) return;
144
+ var params = this.shift();
145
+ if (this.elements.length > 0) params.callback = function () {
146
+ that.run();
147
+ };
148
+ css3Animate(params.id, params);
149
+ },
150
+ shift: function () {
151
+ return this.elements.shift();
152
+ }
153
+ }
154
+ };
155
+ })(jq);
156
+ /**
157
+ * jq.scroller - a scrolling library for jqMobi apps
158
+ * Copyright 2011 - AppMobi
159
+ */
160
+ (function($) {
161
+ var cache = [];
162
+ $.fn["scroller"] = function(opts) {
163
+ var tmp;
164
+ if (opts === undefined && this.length > 0)
165
+ {
166
+ return cache[this[0].id] ? cache[this[0].id] : null;
167
+ }
168
+ for (var i = 0; i < this.length; i++) {
169
+ tmp = new scroller(this[i], opts);
170
+ if (this[i].id)
171
+ cache[this[i].id] = tmp;
172
+ }
173
+ return this.length == 1 ? tmp : this;
174
+ };
175
+ var scroller = (function() {
176
+ if (!window.WebKitCSSMatrix)
177
+ return;
178
+ var translateOpen = 'm11' in new WebKitCSSMatrix() ? "3d(" : "(";
179
+ var translateClose = 'm11' in new WebKitCSSMatrix() ? ",0)" : ")";
180
+ var touchStarted = false;
181
+
182
+ var scroller = function(elID, opts) {
183
+
184
+ if (typeof elID == "string" || elID instanceof String) {
185
+ this.el = document.getElementById(elID);
186
+ } else {
187
+ this.el = elID;
188
+ }
189
+ if (!this.el) {
190
+ alert("Could not find element for scroller " + elID);
191
+ return;
192
+ }
193
+
194
+ if (this instanceof scroller) {
195
+ for (j in opts) {
196
+ this[j] = opts[j];
197
+ }
198
+ } else {
199
+ return new scroller(elID, opts);
200
+ }
201
+ try {
202
+ this.container = this.el.parentNode;
203
+ this.initEvents();
204
+ var windowHeight = window.innerHeight;
205
+ var windowWidth = window.innerWidth;
206
+
207
+
208
+ if (this.verticalScroll && this.verticalScroll == true && this.scrollBars == true) {
209
+ var scrollDiv = createScrollBar(5, 20);
210
+ scrollDiv.style.top = "0px";
211
+ if (this.vScrollCSS)
212
+ scrollDiv.className = this.vScrollCSS;
213
+ scrollDiv.style.opacity = "0";
214
+ this.container.appendChild(scrollDiv);
215
+ this.vscrollBar = scrollDiv;
216
+ scrollDiv = null;
217
+ }
218
+ if (this.horizontalScroll && this.horizontalScroll == true && this.scrollBars == true) {
219
+ var scrollDiv = createScrollBar(20, 5);
220
+ scrollDiv.style.bottom = "0px";
221
+
222
+ if (this.hScrollCSS)
223
+ scrollDiv.className = this.hScrollCSS;
224
+ scrollDiv.style.opacity = "0";
225
+ this.container.appendChild(scrollDiv);
226
+ this.hscrollBar = scrollDiv;
227
+ scrollDiv = null;
228
+ }
229
+ if (this.horizontalScroll)
230
+ this.el.style['float'] = "left";
231
+
232
+ $(this.el).addClass("jq-scrollable");
233
+ this.el.hasScroller=true;
234
+ } catch (e) {
235
+ alert("error adding scroller" + e);
236
+ }
237
+
238
+ };
239
+
240
+ function createScrollBar(width, height) {
241
+ var scrollDiv = document.createElement("div");
242
+ scrollDiv.style.position = 'absolute';
243
+ scrollDiv.style.width = width + "px";
244
+ scrollDiv.style.height = height + "px";
245
+ scrollDiv.style.webkitBorderRadius = "2px";
246
+ scrollDiv.style.opacity = 0;
247
+ scrollDiv.className = 'scrollBar';
248
+ scrollDiv.style.background = "black";
249
+ return scrollDiv;
250
+ }
251
+
252
+ scroller.prototype = {
253
+ lockX: 0,
254
+ lockY: 0,
255
+ boolScrollLock: false,
256
+ currentScrollingObject: null,
257
+ bottomMargin: 0,
258
+ maxTop: 0,
259
+ startTop: 0,
260
+ verticalScroll: true,
261
+ horizontalScroll: false,
262
+ scrollBars: true,
263
+ vscrollBar: null,
264
+ hscrollBar: null,
265
+ hScrollCSS: "scrollBar",
266
+ vScrollCSS: "scrollBar",
267
+ divHeight: 0,
268
+ lastScrollbar: "",
269
+ timeMoved: 0,
270
+ vdistanceMoved: 0,
271
+ hdistanceMoved: 0,
272
+ prevTime: 0,
273
+ finishScrollingObject: null,
274
+ container: null,
275
+ maxLeft: 0,
276
+ startLeft: 0,
277
+ rightMargin: 0,
278
+ divWidth: 0,
279
+ refresh: false,
280
+ refreshFunction: null,
281
+ listeners: {
282
+ start: "",
283
+ move: "",
284
+ end: ""
285
+ },
286
+ elementScrolling:false,
287
+ scrollingFinishCB:false,
288
+ handleEvent: function(e) {
289
+ switch(e.type) {
290
+ case 'touchstart': this.touchStart(e); break;
291
+ case 'touchmove': this.touchMove(e); break;
292
+ case 'touchend': this.touchEnd(e); break;
293
+ }
294
+ },
295
+ initEvents: function () {
296
+ this.el.addEventListener('touchstart', this, false);
297
+ this.el.addEventListener('touchmove', this, false);
298
+ this.el.addEventListener('touchend', this, false);
299
+ },
300
+ removeEvents: function () {
301
+ this.el.removeEventListener('touchstart', this);
302
+ this.el.removeEventListener('touchmove', this);
303
+ this.el.removeEventListener('touchend', this);
304
+ },
305
+ hideScrollbars: function() {
306
+ if (this.hscrollBar)
307
+ {
308
+ this.hscrollBar.style.opacity = 0
309
+ this.hscrollBar.style.webkitTransitionDuration = "0ms";
310
+ }
311
+ if (this.vscrollBar){
312
+ this.vscrollBar.style.opacity = 0
313
+ this.vscrollBar.style.webkitTransitionDuration = "0ms";
314
+ }
315
+ },
316
+ touchStart: function(event) {
317
+ var container = this.container;
318
+ var eleScrolling = this.el;
319
+ that=this;
320
+ if (!container)
321
+ return;
322
+ if(this.elementScrolling){
323
+ clearTimeout(that.scrollingFinishCB);
324
+ }
325
+ touchStarted = true
326
+ if( $(this.el).hasClass("blockscroll"))
327
+ return;
328
+ try {
329
+ // Allow interaction to legit calls, like select boxes, etc.
330
+ if (event.touches[0].target && event.touches[0].target.type != undefined) {
331
+ var tagname = event.touches[0].target.tagName.toLowerCase();
332
+ if (tagname == "select" || tagname == "input" || tagname == "button") // stuff we need to allow
333
+ // access to
334
+ return;
335
+ }
336
+ //Add the pull to refresh text. Not optimal but keeps from others overwriting the content and worrying about italics
337
+ if (this.refresh && this.refresh == true && document.getElementById(this.el.id + "_pulldown") == null) {
338
+ //add the refresh div
339
+ var text = jq("<div id='" + this.el.id + "_pulldown' class='jqscroll_refresh' style='border-radius:.6em;border: 1px solid #2A2A2A;background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0,#666666),color-stop(1,#222222));background:#222222;margin:0px;height:60px;top:0px;margin-left:5px;margin-right:5px;position:absolute;-webkit-transform: translate3d(0, -65px, 0);top:0,left:0,right:0;text-align:center;line-height:60px;color:white;'>Pull to Refresh</div>").get();
340
+ text.style.width = this.container.clientWidth + "px";
341
+ $(this.el).prepend(text);
342
+ }
343
+
344
+
345
+ this.timeMoved = 0;
346
+ this.vdistanceMoved = 0;
347
+ this.hdistanceMoved = 0;
348
+ this.prevTime = null;
349
+ this.finishScrollingObject = null;
350
+ var cnt=$(container);
351
+ this.bottomMargin = container.clientHeight > window.innerHeight ? window.innerHeight : container.clientHeight-numOnly(cnt.css("marginTop"))-numOnly(cnt.css("paddingTop"))-numOnly(cnt.css("marginBottom"))-numOnly(cnt.css("paddingBottom")); //handle css offsets
352
+ this.maxTop = eleScrolling.clientHeight - this.bottomMargin;
353
+ this.divHeight = eleScrolling.clientHeight;
354
+ this.rightMargin = container.clientWidth > window.innerWidth ? window.innerWidth : container.clientWidth-numOnly(cnt.css("marginLeft"))-numOnly(cnt.css("paddingLeft"))-numOnly(cnt.css("marginRight"))-numOnly(cnt.css("paddingRight"));
355
+ this.maxLeft = eleScrolling.clientWidth - this.rightMargin;
356
+ this.divWidth = eleScrolling.clientWidth;
357
+ if (this.maxTop < 0 && this.maxLeft < 0)
358
+ return;
359
+
360
+ this.lockX = event.touches[0].pageX;
361
+ this.lockY = event.touches[0].pageY;
362
+ if (event.touches.length == 1 && this.boolScrollLock == false) {
363
+ try {
364
+ this.startTop = numOnly(new WebKitCSSMatrix(window.getComputedStyle(eleScrolling).webkitTransform).f) - numOnly(this.container.scrollTop);
365
+ this.startLeft = numOnly(new WebKitCSSMatrix(window.getComputedStyle(eleScrolling).webkitTransform).e) - numOnly(this.container.scrollLeft);
366
+
367
+ } catch (e) {
368
+ this.startTop = 0 + this.container.scrollTop;
369
+ this.startLeft = 0 + this.container.scrollLeft;
370
+ console.log("error scroller touchstart " + e);
371
+ }
372
+ this.container.scrollTop = this.container.scrollLeft = 0;
373
+ this.currentScrollingObject = eleScrolling;
374
+ this.scrollerMoveCSS(eleScrolling, {
375
+ x: this.startLeft,
376
+ y: this.startTop
377
+ }, 0);
378
+ if (this.vscrollBar && this.maxTop > 0) {
379
+ this.vscrollBar.style.height = (parseFloat(this.bottomMargin / this.divHeight) * this.bottomMargin) + "px";
380
+ var pos = (this.bottomMargin - numOnly(this.vscrollBar.style.height)) - (((this.maxTop + this.startTop) / this.maxTop) * (this.bottomMargin - numOnly(this.vscrollBar.style.height)));
381
+ this.scrollerMoveCSS(this.vscrollBar, {
382
+ x: 0,
383
+ y: pos
384
+ }, 0);
385
+
386
+
387
+ if (this.container.clientWidth > window.innerWidth)
388
+ this.vscrollBar.style.left = (window.innerWidth - numOnly(this.vscrollBar.style.width) * 3) + "px";
389
+ else
390
+ this.vscrollBar.style.right = "0px";
391
+ this.vscrollBar.webkitTransition = '';
392
+ // this.vscrollBar.style.opacity = 1;
393
+ }
394
+
395
+ if (this.hscrollBar && this.maxLeft > 0) {
396
+ this.hscrollBar.style.width = (parseFloat(this.rightMargin / this.divWidth) * this.rightMargin) + "px";
397
+ var pos = (this.rightMargin - numOnly(this.hscrollBar.style.width)) - (((this.maxTop + this.startLeft) / this.maxtLeft) * (this.rightMargin - numOnly(this.hscrollBar.style.width)));
398
+ this.scrollerMoveCSS(this.hscrollBar, {
399
+ x: pos,
400
+ y: 0
401
+ }, 0);
402
+ if (this.container.clientHeight > window.innerHeight)
403
+ this.hscrollBar.style.top = (window.innerHeight - numOnly(this.hscrollBar.style.height)) + "px";
404
+ else
405
+ this.hscrollBar.style.bottom = numOnly(this.hscrollBar.style.height);
406
+ this.vscrollBar.webkitTransition = '';
407
+
408
+ // this.hscrollBar.style.opacity = 1;
409
+ }
410
+
411
+ //event.preventDefault();
412
+ // get the scrollbar
413
+ }
414
+ } catch (e) {
415
+ alert("error in scrollStart: " + e);
416
+ }
417
+ },
418
+ touchMove: function(event) {
419
+ try {
420
+ if( $(this.el).hasClass("blockscroll"))
421
+ return;
422
+ if (this.currentScrollingObject != null) {
423
+ event.preventDefault();
424
+ var scrollPoints = {
425
+ x: 0,
426
+ y: 0
427
+ };
428
+ var scrollbarPoints = {
429
+ x: 0,
430
+ y: 0
431
+ };
432
+ var newTop = 0,
433
+ prevTop = 0,
434
+ newLeft = 0,
435
+ prevLeft = 0;
436
+
437
+ if (this.verticalScroll && this.maxTop > 0) {
438
+ var deltaY = this.lockY - event.touches[0].pageY;
439
+ deltaY = -deltaY;
440
+ var newTop = this.startTop + deltaY;
441
+ var top = -newTop;
442
+ try {
443
+ var prevTop = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).f);
444
+ } catch (prevTopE) {
445
+ var prevTop = 0;
446
+ }
447
+
448
+ scrollPoints.y = newTop;
449
+ }
450
+ if (this.horizontalScroll && this.maxLeft > 0) {
451
+ var deltaX = this.lockX - event.touches[0].pageX;
452
+ deltaX = -deltaX;
453
+ var newLeft = this.startLeft + deltaX;
454
+ var left = newLeft;
455
+ try {
456
+ var prevLeft = -numOnly((new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).e));
457
+ } catch (prevLeftE) {
458
+ var prevLeft = 0;
459
+ }
460
+ scrollPoints.x = left;
461
+
462
+ }
463
+ var time = 0;
464
+ if ((this.maxTop > 0) && (scrollPoints.y > 0 || scrollPoints.y < -1 * this.maxTop))
465
+ {
466
+
467
+ var overflow = scrollPoints.y > 0 ? (scrollPoints.y) : -1 * (scrollPoints.y + this.maxTop);
468
+ var height = (this.container.clientHeight - overflow) / this.container.clientHeight;
469
+ if (height < .5)
470
+ height = .5;
471
+ if (scrollPoints.y > 0)
472
+ scrollPoints.y = scrollPoints.y * height;
473
+ else {
474
+ scrollPoints.y = scrollPoints.y - ((scrollPoints.y + this.maxTop) * height);
475
+
476
+ }
477
+ }
478
+ this.scrollerMoveCSS(this.currentScrollingObject, scrollPoints, time);
479
+
480
+ if (this.vscrollBar) {
481
+ // We must calculate the position. Since we don't allow
482
+ // the page to scroll to the full content height, we use
483
+ // maxTop as height to work with.
484
+ var pos = (this.bottomMargin - numOnly(this.vscrollBar.style.height)) - (((this.maxTop + newTop) / this.maxTop) * (this.bottomMargin - numOnly(this.vscrollBar.style.height)));
485
+ this.scrollerMoveCSS(this.vscrollBar, {
486
+ x: 0,
487
+ y: pos
488
+ }, 0);
489
+ this.vscrollBar.style.opacity=1;
490
+ }
491
+ if (this.hscrollBar) {
492
+ // We must calculate the position. Since we don't allow
493
+ // the page to scroll to the full content height, we use
494
+ // maxTop as height to work with.
495
+ var pos = (this.rightMargin - numOnly(this.hscrollBar.style.width)) - (((this.maxLeft + newLeft) / this.maxLeft) * (this.rightMargin - numOnly(this.hscrollBar.style.width)));
496
+ this.scrollerMoveCSS(this.hscrollBar, {
497
+ x: pos,
498
+ y: 0
499
+ }, 0);
500
+ this.hscrollBar.style.opacity=1;
501
+ }
502
+
503
+ if (this.prevTime) {
504
+ var tmpDistanceY = Math.abs(prevTop) - Math.abs(newTop);
505
+ var tmpDistanceX = Math.abs(prevLeft) - Math.abs(newLeft);
506
+ var tmpTime = event.timeStamp - this.prevTime;
507
+ if (tmpTime < 500) { // movement is under a second,
508
+ // keep adding the differences
509
+ this.timeMoved += tmpTime;
510
+ this.vdistanceMoved += tmpDistanceY;
511
+ this.hdistanceMoved += tmpDistanceX;
512
+ } else { // We haven't moved in a second, lets reset
513
+ // the variables
514
+ this.timeMoved = 0;
515
+ this.vdistanceMoved = 0;
516
+ this.hdistanceMoved = 0;
517
+ }
518
+ }
519
+ this.prevTime = event.timeStamp;
520
+ }
521
+ } catch (e) {
522
+ alert("error in scrollMove: " + e);
523
+ }
524
+ },
525
+ touchEnd: function(event) {
526
+
527
+ if (this.currentScrollingObject != null) {
528
+ //if (this.timeMoved == 0)
529
+ //{
530
+ //event.preventDefault();
531
+ // if (this.onclick !== undefined)
532
+ // this.onclick();
533
+ // return false;
534
+ // }
535
+
536
+ event.preventDefault();
537
+ this.finishScrollingObject = this.currentScrollingObject;
538
+ this.currentScrollingObject = null;
539
+ var scrollPoints = {
540
+ x: 0,
541
+ y: 0
542
+ };
543
+ var time = 300;
544
+ var moveY;
545
+ if (this.verticalScroll && this.maxTop > 0) {
546
+ var myDistance = -this.vdistanceMoved;
547
+ var time = this.timeMoved;
548
+
549
+
550
+ var move = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).f);
551
+ moveY = move;
552
+
553
+ var data = this.calculateMomentum(myDistance, time);
554
+ time = data.time;
555
+ if (move < 0)
556
+ move = move - data.dist;
557
+
558
+ if (move > 0) {
559
+ move = 0;
560
+ time = 200;
561
+ }
562
+
563
+ if (move < (-this.maxTop)) {
564
+ move = -this.maxTop;
565
+ time = 200;
566
+ }
567
+
568
+ scrollPoints.y = move;
569
+ }
570
+ if (this.horizontalScroll && this.maxLeft > 0) {
571
+ var myDistance = -this.hdistanceMoved;
572
+ var time = this.timeMoved;
573
+
574
+ var move = (new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).e);
575
+ var data = this.calculateMomentum(myDistance, time);
576
+ time = data.time;
577
+ if (move < 0)
578
+ move = move - data.dist;
579
+
580
+ if (move > 0) {
581
+ move = 0;
582
+ time = 200;
583
+ }
584
+
585
+ if (move < (-this.maxLeft)) {
586
+ move = -this.maxLeft;
587
+ time = 200;
588
+ }
589
+ scrollPoints.x = move;
590
+ }
591
+ var that = this;
592
+ if (this.refresh && moveY > 60) {
593
+ if (this.refreshFunction) {
594
+ this.refreshFunction.call();
595
+ }
596
+ }
597
+ if (time < 300)
598
+ time = 300
599
+ this.scrollerMoveCSS(this.finishScrollingObject, scrollPoints, time, "cubic-bezier(0.33,0.66,0.66,1)");
600
+ if (this.vscrollBar) {
601
+ var pos = (this.bottomMargin - numOnly(this.vscrollBar.style.height)) - (((this.maxTop + scrollPoints.y) / this.maxTop) * (this.bottomMargin - numOnly(this.vscrollBar.style.height)));
602
+ if (pos > this.bottomMargin)
603
+ pos = this.bottomMargin;
604
+ if (pos < 0)
605
+ pos = 0;
606
+ this.scrollerMoveCSS(this.vscrollBar, {
607
+ x: 0,
608
+ y: pos
609
+ }, time, "cubic-bezier(0.33,0.66,0.66,1)");
610
+ }
611
+ if (this.hscrollBar) {
612
+ var pos = (this.rightMargin - numOnly(this.hscrollBar.style.width)) - (((this.maxLeft + scrollPoints.x) / this.maxLeft) * (this.rightMargin - numOnly(this.hscrollBar.style.width)));
613
+ if (pos > this.rightMargin)
614
+ pos = this.rightMargin;
615
+ if (pos < 0)
616
+ pos = 0;
617
+ this.scrollerMoveCSS(this.hscrollBar, {
618
+ x: pos,
619
+ y: 0
620
+ }, time, "cubic-bezier(0.33,0.66,0.66,1)");
621
+ }
622
+
623
+ if(isNaN(time))
624
+ that.hideScrollbars(),that.elementScrolling=false
625
+ else
626
+ this.scrollingFinishCB=setTimeout(function(){that.hideScrollbars();that.elementScrolling=false},time);
627
+ this.elementScrolling=true;
628
+ }
629
+ this.hdistanceMoved = 0;
630
+ this.vdistanceMoved = 0;
631
+ touchStarted = false;
632
+ },
633
+
634
+ scrollerMoveCSS: function(el, distanceToMove, time, timingFunction) {
635
+ if (!time)
636
+ time = 0;
637
+ if (!timingFunction)
638
+ timingFunction = "linear";
639
+
640
+ el.style.webkitTransform = "translate" + translateOpen + distanceToMove.x + "px," + distanceToMove.y + "px" + translateClose;
641
+ el.style.webkitTransitionDuration = time + "ms";
642
+ el.style.webkitBackfaceVisiblity = "hidden";
643
+ el.style.webkitTransitionTimingFunction = timingFunction;
644
+ },
645
+
646
+ scrollTo: function(pos, time) {
647
+ if (!time)
648
+ time = 0;
649
+ this.scrollerMoveCSS(this.el, pos, time);
650
+ if (this.vscrollBar) {
651
+ var pos = (this.bottomMargin - numOnly(this.vscrollBar.style.height)) - (((this.maxTop + pos.y) / this.maxTop) * (this.bottomMargin - numOnly(this.vscrollBar.style.height)));
652
+ if (pos > this.bottomMargin)
653
+ pos = this.bottomMargin;
654
+ if (pos < 0)
655
+ pos = 0;
656
+ this.scrollerMoveCSS(this.vscrollBar, {
657
+ x: 0,
658
+ y: pos
659
+ }, time, "ease-out");
660
+ this.vscrollBar.style.opacity = '0';
661
+
662
+ }
663
+ if (this.hscrollBar) {
664
+ var pos = (this.rightMargin - numOnly(this.hscrollBar.style.width)) - (((this.maxLeft + pos.x) / this.maxLeft) * (this.rightMargin - numOnly(this.hscrollBar.style.width)));
665
+ if (pos > this.rightMargin)
666
+ pos = this.rightMargin;
667
+ if (pos < 0)
668
+ pos = 0;
669
+ this.scrollerMoveCSS(this.hscrollBar, {
670
+ x: pos,
671
+ y: 0
672
+ }, time, "ease-out");
673
+ this.hscrollBar.style.opacity = '0';
674
+ }
675
+ },
676
+ scrollBy:function(pos,time) {
677
+ this.startTop = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).f) - numOnly(this.container.scrollTop);
678
+ this.startLeft = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).e) - numOnly(this.container.scrollLeft);
679
+ this.scrollTo({y:this.startTop-pos.y,x:this.startLeft-pos.x},time);
680
+ },
681
+
682
+ //Momentum adapted from iscroll4 http://www.cubiq.org
683
+ calculateMomentum: function(dist, time) {
684
+ var deceleration = 0.0012,
685
+ speed = Math.abs(dist) / time,
686
+ newDist = (speed * speed) / (2 * deceleration), newTime = 0
687
+
688
+ newDist = newDist * (dist < 0 ? -1 : 1);
689
+ newTime = speed / deceleration;
690
+ return {dist: newDist,time: newTime};
691
+ }
692
+ };
693
+ return scroller;
694
+ })();
695
+ })(jq);
696
+ /**
697
+ * jq.popup - a popup/alert library for html5 mobile apps
698
+ * @copyright Indiepath 2011 - Tim Fisher
699
+ * Modifications/enhancements by appMobi for jqMobi
700
+ *
701
+ */
702
+
703
+ /* EXAMPLE
704
+ $('body').popup({
705
+ title:"Alert! Alert!",
706
+ message:"This is a test of the emergency alert system!! Don't PANIC!",
707
+ cancelText:"Cancel me",
708
+ cancelCallback: function(){console.log("cancelled");},
709
+ doneText:"I'm done!",
710
+ doneCallback: function(){console.log("Done for!");},
711
+ cancelOnly:false,
712
+ doneClass:'button',
713
+ cancelClass:'button',
714
+ onShow:function(){console.log('showing popup');}
715
+ autoCloseDone:true, //default is true will close the popup when done is clicked.
716
+ suppressTitle:false //Do not show the title if set to true
717
+ });
718
+
719
+ You can programatically trigger a close by dispatching a "close" event to it.
720
+
721
+ $('body').popup({title:'Alert',id:'myTestPopup'});
722
+ $("#myTestPopup").trigger("close");
723
+
724
+ */
725
+ (function($) {
726
+
727
+ $.fn.popup = function(opts) {
728
+ return new popup(this[0], opts);
729
+ };
730
+ var queue = [];
731
+ var popup = (function() {
732
+ var popup = function(containerEl, opts) {
733
+
734
+ if (typeof containerEl === "string" || containerEl instanceof String) {
735
+ this.container = document.getElementById(containerEl);
736
+ } else {
737
+ this.container = containerEl;
738
+ }
739
+ if (!this.container) {
740
+ alert("Error finding container for popup " + containerEl);
741
+ return;
742
+ }
743
+
744
+ try {
745
+ if (typeof (opts) === "string" || typeof (opts) === "number")
746
+ opts = {message: opts,cancelOnly: "true",cancelText: "OK"};
747
+ this.id = id = opts.id = opts.id || $.uuid(); //opts is passed by reference
748
+ var self = this;
749
+ this.title = opts.suppressTitle?"":(opts.title || "Alert");
750
+ this.message = opts.message || "";
751
+ this.cancelText = opts.cancelText || "Cancel";
752
+ this.cancelCallback = opts.cancelCallback || function() {
753
+ };
754
+ this.cancelClass = opts.cancelClass || "button";
755
+ this.doneText = opts.doneText || "Done";
756
+ this.doneCallback = opts.doneCallback || function(self) {
757
+ self.hide();
758
+ };
759
+ this.doneClass = opts.doneClass || "button";
760
+ this.cancelOnly = opts.cancelOnly || false;
761
+ this.onShow = opts.onShow || function(){};
762
+ this.autoCloseDone=opts.autoCloseDone!==undefined?opts.autoCloseDone:true;
763
+
764
+ queue.push(this);
765
+ if (queue.length == 1)
766
+ this.show();
767
+ } catch (e) {
768
+ console.log("error adding popup " + e);
769
+ }
770
+
771
+ };
772
+
773
+ popup.prototype = {
774
+ id: null,
775
+ title: null,
776
+ message: null,
777
+ cancelText: null,
778
+ cancelCallback: null,
779
+ cancelClass: null,
780
+ doneText: null,
781
+ doneCallback: null,
782
+ doneClass: null,
783
+ cancelOnly: false,
784
+ onShow: null,
785
+ autoCloseDone:true,
786
+ supressTitle:false,
787
+ show: function() {
788
+ var self = this;
789
+ var markup = '<div id="' + this.id + '" class="jqPopup hidden">\
790
+ <header>' + this.title + '</header>\
791
+ <div><div style="width:1px;height:1px;-webkit-transform:translate3d(0,0,0);float:right"></div>' + this.message + '</div>\
792
+ <footer style="clear:both;">\
793
+ <a href="javascript:;" class="'+this.cancelClass+'" id="cancel">' + this.cancelText + '</a>\
794
+ <a href="javascript:;" class="'+this.doneClass+'" id="action">' + this.doneText + '</a>\
795
+ </footer>\
796
+ </div></div>';
797
+ $(this.container).append($(markup));
798
+
799
+ $("#" + this.id).bind("close", function(){
800
+ self.hide();
801
+ })
802
+
803
+ if (this.cancelOnly) {
804
+ $("#" + this.id).find('A#action').hide();
805
+ $("#" + this.id).find('A#cancel').addClass('center');
806
+ }
807
+ $("#" + this.id).find('A').each(function() {
808
+ var button = $(this);
809
+ button.bind('click', function(e) {
810
+ if (button.attr('id') == 'cancel') {
811
+ self.cancelCallback.call(self.cancelCallback, self);
812
+ self.hide();
813
+ } else {
814
+ self.doneCallback.call(self.doneCallback, self);
815
+ if(self.autoCloseDone)
816
+ self.hide();
817
+ }
818
+ e.preventDefault();
819
+ });
820
+ });
821
+ self.positionPopup();
822
+ $.blockUI(0.5);
823
+ $('#' + self.id).removeClass('hidden');
824
+ $('#' + self.id).bind("orientationchange", function() {
825
+ self.positionPopup();
826
+ });
827
+
828
+ this.onShow(this);
829
+
830
+ },
831
+
832
+ hide: function() {
833
+ var self = this;
834
+ $('#' + self.id).addClass('hidden');
835
+ $.unblockUI();
836
+ setTimeout(function() {
837
+ self.remove();
838
+ }, 250);
839
+ },
840
+
841
+ remove: function() {
842
+ var self = this;
843
+ var $el=$("#"+self.id);
844
+ $el.find('BUTTON#action').unbind('click');
845
+ $el.find('BUTTON#cancel').unbind('click');
846
+ $el.unbind("orientationchange").remove();
847
+ queue.splice(0, 1);
848
+ if (queue.length > 0)
849
+ queue[0].show();
850
+ },
851
+
852
+ positionPopup: function() {
853
+ var popup = $('#' + this.id);
854
+ popup.css("top", ((window.innerHeight / 2.5) + window.pageYOffset) - (popup[0].clientHeight / 2) + "px");
855
+ popup.css("left", (window.innerWidth / 2) - (popup[0].clientWidth / 2) + "px");
856
+ }
857
+ };
858
+
859
+ return popup;
860
+ })();
861
+ var uiBlocked = false;
862
+ $.blockUI = function(opacity) {
863
+ if (uiBlocked)
864
+ return;
865
+ opacity = opacity ? " style='opacity:" + opacity + ";'" : "";
866
+ $('BODY').prepend($("<div id='mask'" + opacity + "></div>"));
867
+ $('BODY DIV#mask').bind("touchstart", function(e) {
868
+ e.preventDefault();
869
+ });
870
+ $('BODY DIV#mask').bind("touchmove", function(e) {
871
+ e.preventDefault();
872
+ });
873
+ uiBlocked = true
874
+ };
875
+
876
+ $.unblockUI = function() {
877
+ uiBlocked = false;
878
+ $('BODY DIV#mask').unbind("touchstart");
879
+ $('BODY DIV#mask').unbind("touchmove");
880
+ $("BODY DIV#mask").remove();
881
+ };
882
+ /**
883
+ * Here we override the window.alert function due to iOS eating touch events on native alerts
884
+ */
885
+ window.alert = function(text) {
886
+ if(text===null||text===undefined)
887
+ text="null";
888
+ if($("#jQUi").length>0)
889
+ $("#jQUi").popup(text.toString());
890
+ else
891
+ $(document.body).popup(text.toString());
892
+ }
893
+ window.confirm = function(text) {
894
+ throw "Due to iOS eating touch events from native confirms, please use our popup plugin instead";
895
+ }
896
+ })(jq);
897
+ /**
898
+ * jq.web.actionsheet - a actionsheet for html5 mobile apps
899
+ * Copyright 2012 - AppMobi
900
+ */
901
+ (function($) {
902
+ $.fn["actionsheet"] = function(opts) {
903
+ var tmp;
904
+ for (var i = 0; i < this.length; i++) {
905
+ tmp = new actionsheet(this[i], opts);
906
+ }
907
+ return this.length == 1 ? tmp : this;
908
+ };
909
+ var actionsheet = (function() {
910
+ if (!window.WebKitCSSMatrix)
911
+ return;
912
+
913
+ var actionsheet = function(elID, opts) {
914
+ if (typeof elID == "string" || elID instanceof String) {
915
+ this.el = document.getElementById(elID);
916
+ } else {
917
+ this.el = elID;
918
+ }
919
+ if (!this.el) {
920
+ alert("Could not find element for actionsheet " + elID);
921
+ return;
922
+ }
923
+
924
+ if (this instanceof actionsheet) {
925
+ if(typeof(opts)=="object"){
926
+ for (j in opts) {
927
+ this[j] = opts[j];
928
+ }
929
+ }
930
+ } else {
931
+ return new actionsheet(elID, opts);
932
+ }
933
+
934
+ try {
935
+ var that = this;
936
+ var markStart = '</div><div id="jq_actionsheet"><div style="width:100%">';
937
+ var markEnd = '</div></div>';
938
+ var markup;
939
+ if (typeof opts == "string") {
940
+ markup = $(markStart + opts +"<a href='javascript:;' class='cancel'>Cancel</a>"+markEnd);
941
+ } else if (typeof opts == "object") {
942
+ markup = $(markStart + markEnd);
943
+ var container = $(markup.children().get());
944
+ opts.push({text:"Cancel",cssClasses:"cancel"});
945
+ for (var i = 0; i < opts.length; i++) {
946
+ var item = $('<a href="javascript:;" >' + (opts[i].text || "TEXT NOT ENTERED") + '</a>');
947
+ item[0].onclick = (opts[i].handler || function() {});
948
+ if (opts[i].cssClasses && opts[i].cssClasses.length > 0)
949
+ item.addClass(opts[i].cssClasses);
950
+ container.append(item);
951
+ }
952
+ }
953
+ $(elID).find("#jq_actionsheet").remove();
954
+ $(elID).find("#jq_action_mask").remove();
955
+ actionsheetEl = $(elID).append(markup);
956
+
957
+ markup.get().style.webkitTransition="all 0ms";
958
+ markup.css("-webkit-transform", "translate3d(0,"+(window.innerHeight*2) + "px,0)");
959
+ this.el.style.overflow = "hidden";
960
+ markup.on("click", "a",function(){that.hideSheet()});
961
+ this.activeSheet=markup;
962
+ $(elID).append('<div id="jq_action_mask" style="position:absolute;top:0px;left:0px;right:0px;bottom:0px;z-index:9998;background:rgba(0,0,0,.4)"/>');
963
+ setTimeout(function(){
964
+ markup.get().style.webkitTransition="all 200ms";
965
+ var height=window.innerHeight-parseInt(markup.css("height"));
966
+ markup.css("-webkit-transform", "translate3d(0,"+(height)+"px,0)");
967
+ },10);
968
+ } catch (e) {
969
+ alert("error adding actionsheet" + e);
970
+ }
971
+ };
972
+ actionsheet.prototype = {
973
+ activeSheet:null,
974
+ hideSheet: function() {
975
+ var that=this;
976
+ this.activeSheet.off("click","a",function(){that.hideSheet()});
977
+ $(this.el).find("#jq_action_mask").remove();
978
+ this.activeSheet.get().style.webkitTransition="all 0ms";
979
+ var markup = this.activeSheet;
980
+ var theEl = this.el;
981
+ setTimeout(function(){
982
+
983
+ markup.get().style.webkitTransition="all 500ms";
984
+ markup.css("-webkit-transform", "translate3d(0,"+(window.innerHeight*2) + "px,0)");
985
+ setTimeout(function(){
986
+ markup.remove();
987
+ markup=null;
988
+ theEl.style.overflow = "none";
989
+ },500);
990
+ },10);
991
+ }
992
+ };
993
+ return actionsheet;
994
+ })();
995
+ })(jq);
996
+
997
+ /*
998
+ * jq.web.passwordBox - password box replacement for html5 mobile apps on android due to a bug with CSS3 translate3d
999
+ * @copyright 2011 - AppMobi
1000
+ */
1001
+ (function ($) {
1002
+ $["passwordBox"] = function () {
1003
+
1004
+ return new passwordBox();
1005
+ };
1006
+
1007
+ var passwordBox = function () {
1008
+ this.oldPasswords = {};
1009
+ };
1010
+ passwordBox.prototype = {
1011
+ showPasswordPlainText: false,
1012
+ getOldPasswords: function (elID) {
1013
+ // if ($.os.android == false) return; - iOS users seem to want this too, so we'll let everyone join the party
1014
+ var container = elID && document.getElementById(elID) ? document.getElementById(elID) : document;
1015
+ if (!container) {
1016
+ alert("Could not find container element for passwordBox " + elID);
1017
+ return;
1018
+ }
1019
+ var sels = container.getElementsByTagName("input");
1020
+
1021
+ var that = this;
1022
+ for (var i = 0; i < sels.length; i++) {
1023
+ if (sels[i].type != "password") continue;
1024
+
1025
+ sels[i].type = "text";
1026
+ sels[i].style['-webkit-text-security'] = "disc";
1027
+ }
1028
+ },
1029
+
1030
+ changePasswordVisiblity: function (what, id) {
1031
+ what = parseInt(what);
1032
+ var theEl = document.getElementById(id);
1033
+ if (what == 1) { //show
1034
+ theEl.style['-webkit-text-security'] = "none";
1035
+ } else {
1036
+ theEl.style['-webkit-text-security'] = "disc";
1037
+ }
1038
+ theEl = null;
1039
+ }
1040
+ };
1041
+ })(jq);
1042
+ /*
1043
+ * Copyright: AppMobi
1044
+ * Description: This script will replace all drop downs with friendly select controls. Users can still interact
1045
+ * with the old drop down box as normal with javascript, and this will be reflected
1046
+
1047
+ */
1048
+ (function($) {
1049
+ $['selectBox'] = {
1050
+ oldSelects: {},
1051
+ scroller: null,
1052
+ getOldSelects: function(elID) {
1053
+ if ($.os.android == false)
1054
+ return;
1055
+ if (!$.fn['scroller']) {
1056
+ alert("This library requires jq.web.Scroller");
1057
+ return;
1058
+ }
1059
+ var container = elID && document.getElementById(elID) ? document.getElementById(elID) : document;
1060
+ if (!container) {
1061
+ alert("Could not find container element for jq.web.selectBox " + elID);
1062
+ return;
1063
+ }
1064
+ var sels = container.getElementsByTagName("select");
1065
+ var that = this;
1066
+ for (var i = 0; i < sels.length; i++) {
1067
+ if (this.oldSelects[sels[i].id])
1068
+ continue;
1069
+ (function(theSel) {
1070
+ var fakeInput = document.createElement("div");
1071
+ var selWidth = parseInt(theSel.style.width) > 0 ? parseInt(theSel.style.width) : 100;
1072
+ var selHeight = parseInt(theSel.style.height) > 0 ? parseInt(theSel.style.height) : 20;
1073
+ fakeInput.style.width = selWidth + "px";
1074
+ fakeInput.style.height = selHeight + "px";
1075
+ fakeInput.style.position = "absolute";
1076
+ fakeInput.style.left = "0px";
1077
+ fakeInput.style.top = "0px";
1078
+ fakeInput.style.zIndex = "1";
1079
+ if (theSel.value)
1080
+ fakeInput.innerHTML = theSel.options[theSel.selectedIndex].text;
1081
+ fakeInput.style.background = "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAeCAIAAABFWWJ4AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkM1NjQxRUQxNUFEODExRTA5OUE3QjE3NjI3MzczNDAzIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOkM1NjQxRUQyNUFEODExRTA5OUE3QjE3NjI3MzczNDAzIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6QzU2NDFFQ0Y1QUQ4MTFFMDk5QTdCMTc2MjczNzM0MDMiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6QzU2NDFFRDA1QUQ4MTFFMDk5QTdCMTc2MjczNzM0MDMiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz6YWbdCAAAAlklEQVR42mIsKChgIBGwAHFPTw/xGkpKSlggrG/fvhGjgYuLC0gyMZAOoPb8//9/0Or59+8f8XrICQN66SEnDOgcp3AgKiqKqej169dY9Hz69AnCuHv3rrKyMrIKoAhcVlBQELt/gIqwstHD4B8quH37NlAQSKKJEwg3iLbBED8kpeshoGcwh5uuri5peoBFMEluAwgwAK+5aXfuRb4gAAAAAElFTkSuQmCC') right top no-repeat";
1082
+ fakeInput.style.backgroundColor = "white";
1083
+ fakeInput.className = "jqmobiSelect_fakeInput " + theSel.className;
1084
+ fakeInput.id = theSel.id + "_jqmobiSelect";
1085
+
1086
+ fakeInput.style.border = "1px solid gray";
1087
+ fakeInput.style.color = "black";
1088
+ fakeInput.linkId = theSel.id;
1089
+ fakeInput.onclick = function(e) {
1090
+ that.initDropDown(this.linkId);
1091
+ };
1092
+ theSel.parentNode.appendChild(fakeInput);
1093
+ theSel.parentNode.style.position = "relative";
1094
+ theSel.style.display = "none";
1095
+ theSel.style.webkitAppearance = "none";
1096
+ // Create listeners to watch when the select value has changed.
1097
+ // This is needed so the users can continue to interact as normal,
1098
+ // via jquery or other frameworks
1099
+ for (var j = 0; j < theSel.options.length; j++) {
1100
+ if (theSel.options[j].selected) {
1101
+ fakeInput.value = theSel.options[j].text;
1102
+ }
1103
+ theSel.options[j].watch( "selected", function(prop, oldValue, newValue) {
1104
+ if (newValue == true) {
1105
+ that.updateMaskValue(this.parentNode.id, this.text, this.value);
1106
+ this.parentNode.value = this.value;
1107
+ }
1108
+ return newValue;
1109
+ });
1110
+ }
1111
+ theSel.watch("selectedIndex", function(prop, oldValue, newValue) {
1112
+ if (this.options[newValue]) {
1113
+ that.updateMaskValue(this.id, this.options[newValue].text, this.options[newValue].value);
1114
+ this.value = this.options[newValue].value;
1115
+ }
1116
+ return newValue;
1117
+ });
1118
+
1119
+ fakeInput = null;
1120
+ imageMask = null;
1121
+ that.oldSelects[theSel.id] = 1;
1122
+
1123
+
1124
+ })(sels[i]);
1125
+ }
1126
+ that.createHtml();
1127
+ },
1128
+ updateDropdown: function(id) {
1129
+ var el = document.getElementById(id);
1130
+ if (!el)
1131
+ return;
1132
+ for (var j = 0; j < el.options.length; j++) {
1133
+ if (el.options[j].selected)
1134
+ fakeInput.value = el.options[j].text;
1135
+ el.options[j].watch("selected", function(prop, oldValue, newValue) {
1136
+ if (newValue == true) {
1137
+ that.updateMaskValue(this.parentNode.id, this.text, this.value);
1138
+ this.parentNode.value = this.value;
1139
+ }
1140
+ return newValue;
1141
+ });
1142
+ }
1143
+ el = null;
1144
+ },
1145
+ initDropDown: function(elID) {
1146
+
1147
+ var that = this;
1148
+ var el = document.getElementById(elID);
1149
+ if (el.disabled)
1150
+ return;
1151
+ if (!el || !el.options || el.options.length == 0)
1152
+ return;
1153
+ var htmlTemplate = "";
1154
+ var foundInd = 0;
1155
+ document.getElementById("jqmobiSelectBoxScroll").innerHTML = "";
1156
+
1157
+ document.getElementById("jqmobiSelectBoxHeaderTitle").innerHTML = (el.name != undefined && el.name != "undefined" && el.name != "" ? el.name : elID);
1158
+
1159
+ for (var j = 0; j < el.options.length; j++) {
1160
+ var currInd = j;
1161
+ el.options[j].watch( "selected", function(prop, oldValue, newValue) {
1162
+ if (newValue == true) {
1163
+ that.updateMaskValue(this.parentNode.id, this.text, this.value);
1164
+ this.parentNode.value = this.value;
1165
+ }
1166
+ return newValue;
1167
+ });
1168
+ var checked = (el.value == el.options[j].value) ? true : false;
1169
+ var button = "";
1170
+ var bg = "background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.17, rgb(102,102,102)),color-stop(0.59, rgb(94,94,94)))";
1171
+ var foundID;
1172
+ var div = document.createElement("div");
1173
+ div.className = "jqmobiSelectRow";
1174
+ if (checked) {
1175
+ bg = "background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.17, rgb(8,8,8)),color-stop(0.59, rgb(38,38,38)))";
1176
+ button = "checked";
1177
+ foundInd = j;
1178
+ foundID = "id='jqmobiSelectBox_found'";
1179
+ div.className = "jqmobiSelectRowFound";
1180
+ } else {
1181
+ foundID = "";
1182
+ }
1183
+
1184
+ div.id = foundID;
1185
+ div.style.cssText = ";line-height:40px;font-size:14px;padding-left:10px;height:40px;width:100%;position:relative;width:100%;border-bottom:1px solid black;background:white;";
1186
+ var anchor = document.createElement("a");
1187
+ anchor.href = "javascript:;";
1188
+ div.tmpValue = j;
1189
+ div.onclick = function(e) {
1190
+ that.setDropDownValue(elID, this.tmpValue);
1191
+ };
1192
+ anchor.style.cssText = "text-decoration:none;color:black;";
1193
+ anchor.innerHTML = el.options[j].text;
1194
+ var span = document.createElement("span");
1195
+ span.style.cssText = "float:right;margin-right:20px;margin-top:-2px";
1196
+ var rad = document.createElement("button");
1197
+ if (foundID) {
1198
+ rad.style.cssText = "background: #000;padding: 0px 0px;border-radius:15px;border:3px solid black;";
1199
+ rad.className = "jqmobiSelectRowButtonFound";
1200
+ } else {
1201
+ rad.style.cssText = "background: #ffffff;padding: 0px 0px;border-radius:15px;border:3px solid black;";
1202
+ rad.className = "jqmobiSelectRowButton";
1203
+ }
1204
+ rad.style.width = "20px";
1205
+ rad.style.height = "20px";
1206
+
1207
+ rad.checked = button;
1208
+
1209
+ anchor.className = "jqmobiSelectRowText";
1210
+ span.appendChild(rad);
1211
+ div.appendChild(anchor);
1212
+ div.appendChild(span);
1213
+
1214
+ document.getElementById("jqmobiSelectBoxScroll").appendChild(div);
1215
+
1216
+ span = null;
1217
+ rad = null;
1218
+ anchor = null;
1219
+ }
1220
+ try {
1221
+ document.getElementById("jqmobiSelectModal").style.display = 'block';
1222
+ } catch (e) {
1223
+ console.log("Error showing div " + e);
1224
+ }
1225
+ try {
1226
+ if (div) {
1227
+ var scrollThreshold = numOnly(div.style.height);
1228
+ var offset = numOnly(document.getElementById("jqmobiSelectBoxHeader").style.height);
1229
+
1230
+ if (foundInd * scrollThreshold + offset >= numOnly(document.getElementById("jqmobiSelectBoxFix").clientHeight) - offset)
1231
+ var scrollToPos = (foundInd) * -scrollThreshold + offset;
1232
+ else
1233
+ scrollToPos = 0;
1234
+ this.scroller.scrollTo({
1235
+ x: 0,
1236
+ y: scrollToPos
1237
+ });
1238
+ }
1239
+ } catch (e) {
1240
+ console.log("error init dropdown" + e);
1241
+ }
1242
+ div = null;
1243
+ el = null;
1244
+ },
1245
+ updateMaskValue: function(elID, value, val2) {
1246
+
1247
+ var el = document.getElementById(elID + "_jqmobiSelect");
1248
+ var el2 = document.getElementById(elID);
1249
+ if (el)
1250
+ el.innerHTML = value;
1251
+ if (typeof (el2.onchange) == "function")
1252
+ el2.onchange(val2);
1253
+ el = null;
1254
+ el2 = null;
1255
+ },
1256
+ setDropDownValue: function(elID, value) {
1257
+
1258
+ var el = document.getElementById(elID);
1259
+ if (el) {
1260
+ el.selectedIndex = value;
1261
+ $(el).trigger("change");
1262
+ }
1263
+ this.scroller.scrollTo({
1264
+ x: 0,
1265
+ y: 0
1266
+ });
1267
+ this.hideDropDown();
1268
+ el = null;
1269
+ },
1270
+ hideDropDown: function() {
1271
+ document.getElementById("jqmobiSelectModal").style.display = 'none';
1272
+ document.getElementById("jqmobiSelectBoxScroll").innerHTML = "";
1273
+ },
1274
+ createHtml: function() {
1275
+ var that = this;
1276
+ if (document.getElementById("jqmobiSelectBoxContainer")) {
1277
+ return;
1278
+ }
1279
+ var modalDiv = document.createElement("div");
1280
+
1281
+ modalDiv.style.cssText = "position:absolute;top:0px;bottom:0px;left:0px;right:0px;background:rgba(0,0,0,.7);z-index:200000;display:none;";
1282
+ modalDiv.id = "jqmobiSelectModal";
1283
+
1284
+ var myDiv = document.createElement("div");
1285
+ myDiv.id = "jqmobiSelectBoxContainer";
1286
+ myDiv.style.cssText = "position:absolute;top:8%;bottom:10%;display:block;width:90%;margin:auto;margin-left:5%;height:90%px;background:white;color:black;border:1px solid black;border-radius:6px;";
1287
+ myDiv.innerHTML = "<div id='jqmobiSelectBoxHeader' style=\"display:block;font-family:'Eurostile-Bold', Eurostile, Helvetica, Arial, sans-serif;color:#fff;font-weight:bold;font-size:18px;line-height:34px;height:34px; text-transform:uppercase;text-align:left;text-shadow:rgba(0,0,0,.9) 0px -1px 1px; padding: 0px 8px 0px 8px; border-top-left-radius:5px; border-top-right-radius:5px; -webkit-border-top-left-radius:5px; -webkit-border-top-right-radius:5px; background:#39424b; margin:1px;\"><div style='float:left;' id='jqmobiSelectBoxHeaderTitle'></div><div style='float:right;width:60px;margin-top:-5px'><div id='jqmobiSelectClose' class='button' style='width:60px;height:32px;line-height:32px;'>Close</div></div></div>";
1288
+ myDiv.innerHTML += '<div id="jqmobiSelectBoxFix" style="position:relative;height:90%;background:white;overflow:hidden;width:100%;"><div id="jqmobiSelectBoxScroll"></div></div>';
1289
+ var that = this;
1290
+ modalDiv.appendChild(myDiv);
1291
+
1292
+ $(document).ready(function() {
1293
+
1294
+ if(jq("#jQUi"))
1295
+ jq("#jQUi").append(modalDiv);
1296
+ else
1297
+ document.body.appendChild(modalDiv);
1298
+ var close = $("#jqmobiSelectClose").get();
1299
+ close.onclick = function() {
1300
+ that.hideDropDown();
1301
+ };
1302
+
1303
+ var styleSheet = $("<style>.jqselectscrollBarV{opacity:1 !important;}</style>").get();
1304
+ document.body.appendChild(styleSheet);
1305
+ try {
1306
+ that.scroller = $("#jqmobiSelectBoxScroll").scroller({
1307
+ scroller: false,
1308
+ verticalScroll: true,
1309
+ vScrollCSS: "jqselectscrollBarV"
1310
+ });
1311
+
1312
+ } catch (e) {
1313
+ console.log("Error creating select html " + e);
1314
+ }
1315
+ modalDiv = null;
1316
+ myDiv = null;
1317
+ styleSheet = null;
1318
+ });
1319
+ }
1320
+ };
1321
+ //The following is based off Eli Grey's shim
1322
+ //https://gist.github.com/384583
1323
+ //We use HTMLElement to not cause problems with other objects
1324
+ if (!HTMLElement.prototype.watch) {
1325
+ HTMLElement.prototype.watch = function (prop, handler) {
1326
+ var oldval = this[prop], newval = oldval,
1327
+ getter = function () {
1328
+ return newval;
1329
+ },
1330
+ setter = function (val) {
1331
+ oldval = newval;
1332
+ return newval = handler.call(this, prop, oldval, val);
1333
+ };
1334
+ if (delete this[prop]) { // can't watch constants
1335
+ if (HTMLElement.defineProperty) { // ECMAScript 5
1336
+ HTMLElement.defineProperty(this, prop, {
1337
+ get: getter,
1338
+ set: setter,
1339
+ enumerable: false,
1340
+ configurable: true
1341
+ });
1342
+ } else if (HTMLElement.prototype.__defineGetter__ && HTMLElement.prototype.__defineSetter__) { // legacy
1343
+ HTMLElement.prototype.__defineGetter__.call(this, prop, getter);
1344
+ HTMLElement.prototype.__defineSetter__.call(this, prop, setter);
1345
+ }
1346
+ }
1347
+ };
1348
+ }
1349
+ if (!HTMLElement.prototype.unwatch) {
1350
+ HTMLElement.prototype.unwatch = function (prop) {
1351
+ var val = this[prop];
1352
+ delete this[prop]; // remove accessors
1353
+ this[prop] = val;
1354
+ };
1355
+ }
1356
+ })(jq);
1357
+ /**
1358
+ * jq.ui - A User Interface library for creating jqMobi applications
1359
+ *
1360
+ * @copyright 2011
1361
+ * @author AppMobi
1362
+ */(function($) {
1363
+
1364
+ var hasLaunched = false;
1365
+ var startPath = window.location.pathname;
1366
+ var defaultHash = window.location.hash;
1367
+ var previousTarget = defaultHash;
1368
+
1369
+
1370
+ if(!("pushState" in window.history)){
1371
+ window.history['pushState']=function(){}
1372
+ }
1373
+ var ui = function() {
1374
+ // Init the page
1375
+ var that = this;
1376
+ if (window.AppMobi)
1377
+ document.addEventListener("appMobi.device.ready", function() {
1378
+ that.hasLaunched = true;
1379
+ if (that.autoLaunch) {
1380
+ that.launch();
1381
+ }
1382
+ }, false);
1383
+ else if (document.readyState == "complete" || document.readyState == "loaded") {
1384
+ that.hasLaunched = true;
1385
+ if (that.autoLaunch) {
1386
+ that.launch();
1387
+ }
1388
+ } else
1389
+ document.addEventListener("DOMContentLoaded", function() {
1390
+ that.hasLaunched = true;
1391
+ if (that.autoLaunch) {
1392
+ that.launch();
1393
+ }
1394
+ }, false);
1395
+ if (!window.AppMobi)
1396
+ AppMobi = {}, AppMobi.webRoot = "";
1397
+ window.addEventListener("popstate", function() {
1398
+ that.goBack();
1399
+ }, false);
1400
+
1401
+ /**
1402
+ * Helper function to setup the transition objects
1403
+ * Custom transitions can be added via $.ui.availableTransitions
1404
+ ```
1405
+ $.ui.availableTransitions['none']=function();
1406
+ ```
1407
+ */
1408
+ (function(obj) {
1409
+ obj.availableTransitions = {};
1410
+ obj.availableTransitions['none'] = that.noTransition;
1411
+ obj.availableTransitions['default'] = that.noTransition;
1412
+ })(this);
1413
+ };
1414
+
1415
+
1416
+ ui.prototype = {
1417
+ fixAndroidInputs:true,
1418
+ isAjaxApp:false,
1419
+ isAppMobi: false,
1420
+ showLoading:true,
1421
+ navbar: "",
1422
+ header: "",
1423
+ viewportContainer: "",
1424
+ backButton: "",
1425
+ remotePages: {},
1426
+ history: [],
1427
+ homeDiv: "",
1428
+ screenWidth: "",
1429
+ content: "",
1430
+ modalWindow: "",
1431
+ customFooter: false,
1432
+ defaultFooter: "",
1433
+ defaultHeader: null,
1434
+ customMenu: false,
1435
+ defaultMenu: "",
1436
+ _readyFunc: null,
1437
+ doingTransition: false,
1438
+ passwordBox: new jq.passwordBox(),
1439
+ selectBox: jq.selectBox,
1440
+ ajaxUrl: "",
1441
+ transitionType: "slide",
1442
+ scrollingDivs: [],
1443
+ firstDiv: "",
1444
+ remoteJSPages: {},
1445
+ hasLaunched: false,
1446
+ launchCompleted: false,
1447
+ activeDiv: "",
1448
+
1449
+
1450
+ css3animate: function(el, opts) {
1451
+ el = jq(el);
1452
+ if (!el.__proto__["css3Animate"])
1453
+ throw "css3Animate plugin is required";
1454
+ return el.css3Animate(opts);
1455
+ },
1456
+ /**
1457
+ * This is the time transitions will run for.
1458
+ ```
1459
+ $.ui.transitionTime='400ms';
1460
+ ```
1461
+ * @title $.ui.transitionTime;
1462
+ */
1463
+ transitionTime:"500",
1464
+ /**
1465
+ * this is a boolean when set to true (default) it will load that panel when the app is started
1466
+ ```
1467
+ $.ui.loadDefaultHash=false; //Never load the page from the hash when the app is started
1468
+ $.ui.loadDefaultHash=true; //Default
1469
+ ```
1470
+ *@title $.ui.loadDefaultHash
1471
+ */
1472
+ loadDefaultHash: true,
1473
+
1474
+ /**
1475
+ * This is a boolean that when set to true will add "&cache=_rand_" to any ajax loaded link
1476
+ ```
1477
+ $.ui.useAjaxCacheBuster=true;
1478
+ ```
1479
+ *@title $.ui.useAjaxCacheBuster
1480
+ */
1481
+ useAjaxCacheBuster: false,
1482
+ /**
1483
+ * This is a shorthand call to the jq.actionsheet plugin. We wire it to the jQUi div automatically
1484
+ ```
1485
+ $.ui.actionsheet("<a href='javascript:;' class='button'>Settings</a> <a href='javascript:;' class='button red'>Logout</a>")
1486
+ $.ui.actionsheet("[{
1487
+ text: 'back',
1488
+ cssClasses: 'red',
1489
+ handler: function () { $.ui.goBack(); ; }
1490
+ }, {
1491
+ text: 'show alert 5',
1492
+ cssClasses: 'blue',
1493
+ handler: function () { alert("hi"); }
1494
+ }, {
1495
+ text: 'show alert 6',
1496
+ cssClasses: '',
1497
+ handler: function () { alert("goodbye"); }
1498
+ }]");
1499
+ ```
1500
+ * @param {String,Array} links
1501
+ * @title $.ui.actionsheet()
1502
+ */
1503
+ actionsheet: function(opts) {
1504
+ el = jq("#jQUi");
1505
+ if (!el.__proto__["actionsheet"])
1506
+ throw "actionsheet plugin is required";
1507
+ return el.actionsheet(opts);
1508
+ },
1509
+ /**
1510
+ * This is a wrapper to jq.popup.js plugin. If you pass in a text string, it acts like an alert box and just gives a message
1511
+ ```
1512
+ $.ui.popup(opts);
1513
+ $.ui.popup( {
1514
+ title:"Alert! Alert!",
1515
+ message:"This is a test of the emergency alert system!! Don't PANIC!",
1516
+ cancelText:"Cancel me",
1517
+ cancelCallback: function(){console.log("cancelled");},
1518
+ doneText:"I'm done!",
1519
+ doneCallback: function(){console.log("Done for!");},
1520
+ cancelOnly:false
1521
+ });
1522
+ $.ui.popup('Hi there');
1523
+ ```
1524
+ * @param {Object|String} options
1525
+ * @title $.ui.popup(opts)
1526
+ */
1527
+ popup: function(opts) {
1528
+ el = jq("#jQUi");
1529
+ if (!el.__proto__["popup"])
1530
+ throw "popup plugin is required";
1531
+ return el.popup(opts);
1532
+ },
1533
+
1534
+ /**
1535
+ *This will throw up a mask and block the UI
1536
+ ```
1537
+ $.ui.blockUI(.9)
1538
+ ````
1539
+ * @param {Float} opacity
1540
+ * @title $.ui.blockUI(opacity)
1541
+ */
1542
+ blockUI: function(opacity) {
1543
+ $.blockUI(opacity);
1544
+ },
1545
+ /**
1546
+ *This will remove the UI mask
1547
+ ```
1548
+ $.ui.unblockUI()
1549
+ ````
1550
+ * @title $.ui.unblockUI()
1551
+ */
1552
+ unblockUI: function() {
1553
+ $.unblockUI();
1554
+ },
1555
+ /**
1556
+ * Will remove the bottom nav bar menu from your application
1557
+ ```
1558
+ $.ui.removeFooterMenu();
1559
+ ```
1560
+ * @title $.ui.removeFooterMenu
1561
+ */
1562
+ removeFooterMenu: function() {
1563
+ jq("#navbar").hide();
1564
+ jq("#content").css("bottom", "0px");
1565
+ this.showNavMenu = false;
1566
+ },
1567
+ /**
1568
+ * Boolean if you want to show the bottom nav menu.
1569
+ ```
1570
+ $.ui.showNavMenu = false;
1571
+ ```
1572
+ * @title $.ui.showNavMenu
1573
+ */
1574
+ showNavMenu: true,
1575
+ /**
1576
+ * Boolean if you want to auto launch jqUi
1577
+ ```
1578
+ $.ui.autoLaunch = false; //
1579
+ * @title $.ui.autoLaunch
1580
+ */
1581
+ autoLaunch: true,
1582
+ /**
1583
+ * Boolean if you want to show the back button
1584
+ ```
1585
+ $.ui.showBackButton = false; //
1586
+ * @title $.ui.showBackButton
1587
+ */
1588
+ showBackbutton: true,
1589
+ /**
1590
+ * @api private
1591
+ */
1592
+ backButtonText: "",
1593
+ /**
1594
+ * Boolean if you want to reset the scroller position when navigating panels. Default is true
1595
+ ```
1596
+ $.ui.resetScrollers=false; //Do not reset the scrollers when switching panels
1597
+ ```
1598
+ * @title $.ui.resetScrollers
1599
+ */
1600
+ resetScrollers: true,
1601
+ /**
1602
+ * function to fire when jqUi is ready and completed launch
1603
+ ```
1604
+ $.ui.ready(function(){console.log('jqUi is ready');});
1605
+ ```
1606
+ * @param {Function} function to execute
1607
+ * @title $.ui.ready
1608
+ */
1609
+ ready: function(param) {
1610
+ if (this.launchCompleted)
1611
+ param();
1612
+ else
1613
+ document.addEventListener("jq.ui.ready", param, false);
1614
+ },
1615
+ /**
1616
+ * Override the back button class name
1617
+ ```
1618
+ $.ui.setBackButtonStyle('newClass');
1619
+ ```
1620
+ * @param {String} new class name
1621
+ * @title $.ui.setBackButtonStyle(class)
1622
+ */
1623
+ setBackButtonStyle: function(className) {
1624
+ $am("backButton").className = className;
1625
+ },
1626
+ /**
1627
+ * Initiate a back transition
1628
+ ```
1629
+ $.ui.goBack()
1630
+ ```
1631
+
1632
+ * @title $.ui.goBack()
1633
+ */
1634
+ goBack: function() {
1635
+
1636
+ if (this.history.length > 0) {
1637
+ var tmpEl = this.history.pop();
1638
+ this.loadContent(tmpEl.target + "", 0, 1, tmpEl.transition);
1639
+ this.transitionType = tmpEl.transition;
1640
+ }
1641
+ },
1642
+ /**
1643
+ * Clear the history queue
1644
+ ```
1645
+ $.ui.clearHistory()
1646
+ ```
1647
+
1648
+ * @title $.ui.clearHistory()
1649
+ */
1650
+ clearHistory: function() {
1651
+ this.history = [];
1652
+ this.backButton.style.visibility = "hidden";
1653
+ },
1654
+ /**
1655
+ * Update a badge on the selected target. Position can be
1656
+ bl = bottom left
1657
+ tl = top left
1658
+ br = bottom right
1659
+ tr = top right (default)
1660
+ ```
1661
+ $.ui.updateBadge('#mydiv','3','bl');
1662
+ ```
1663
+ * @param {String} target
1664
+ * @param {String} Value
1665
+ * @param {String} [position]
1666
+ * @title $.ui.updateBadge(target,value,[position])
1667
+ */
1668
+ updateBadge: function(target, value, position) {
1669
+ if (position === undefined)
1670
+ position = "";
1671
+
1672
+ if (target[0] != "#")
1673
+ target = "#" + target;
1674
+ var badge = jq(target).find("span.jq-badge");
1675
+ if (badge.length == 0) {
1676
+ if (jq(target).css("position") != "absolute")
1677
+ jq(target).css("position", "relative");
1678
+ badge = jq(target).append("<span class='jq-badge " + position + "'>" + value + "</span>");
1679
+ } else
1680
+ badge.html(value);
1681
+ badge.data("ignore-pressed","true");
1682
+
1683
+ },
1684
+ /**
1685
+ * Removes a badge from the selected target.
1686
+ ```
1687
+ $.ui.removeBadge('#mydiv');
1688
+ ```
1689
+ * @param {String} target
1690
+ * @title $.ui.removeBadge(target)
1691
+ */
1692
+ removeBadge: function(target) {
1693
+ jq(target).find("span.jq-badge").remove();
1694
+ },
1695
+ /**
1696
+ * Toggles the bottom nav nav menu. Force is a boolean to force show or hide.
1697
+ ```
1698
+ $.ui.toggleNavMenu();//toggle it
1699
+ $.ui.toggleNavMenu(true); //force show it
1700
+ ```
1701
+ * @param {Boolean} [force]
1702
+ * @title $.ui.toggleNavMenu([force])
1703
+ */
1704
+ toggleNavMenu: function(force) {
1705
+ if (!jq.ui.showNavMenu)
1706
+ return;
1707
+ if (jq("#navbar").css("display") != "none" && ((force !== undefined && force !== true) || force === undefined)) {
1708
+ jq("#content").css("bottom", "0px");
1709
+ jq("#navbar").hide();
1710
+ } else if (force === undefined || (force !== undefined && force === true)) {
1711
+ jq("#navbar").show();
1712
+ jq("#content").css("bottom", jq("#navbar").css("height"));
1713
+
1714
+ }
1715
+ },
1716
+ /**
1717
+ * Toggles the top header menu.
1718
+ ```
1719
+ $.ui.toggleHeaderMenu();//toggle it
1720
+ ```
1721
+ * @param {Boolean} [force]
1722
+ * @title $.ui.toggleHeaderMenu([force])
1723
+ */
1724
+ toggleHeaderMenu: function(force) {
1725
+
1726
+ if (jq("#header").css("display") != "none" && ((force !== undefined && force !== true) || force === undefined)) {
1727
+ jq("#content").css("top", "0px");
1728
+ jq("#header").hide();
1729
+ } else if (force === undefined || (force !== undefined && force === true)) {
1730
+ jq("#header").show();
1731
+ jq("#content").css("top", jq("#header").css("height"));
1732
+
1733
+ }
1734
+ },
1735
+ /**
1736
+ * Toggles the side menu. Force is a boolean to force show or hide.
1737
+ ```
1738
+ $.ui.toggleSideMenu();//toggle it
1739
+ ```
1740
+ * @param {Boolean} [force]
1741
+ * @title $.ui.toggleSideMenu([force])
1742
+ */
1743
+ toggleSideMenu: function(force) {
1744
+ var that = this;
1745
+ if (!jq("#content").hasClass("hasMenu"))
1746
+ return;
1747
+ if (jq("#menu").css("display") != "block" && ((force !== undefined && force !== false) || force === undefined)) {
1748
+ this.scrollingDivs["menu_scroller"].initEvents();
1749
+ jq("#menu").show();
1750
+ window.setTimeout(function() {
1751
+ jq("#menu").addClass("on");
1752
+ jq("#header").addClass("on");
1753
+ jq("#navbar").addClass("on");
1754
+ jq("#content").addClass("on");
1755
+ }, 1); //needs to run after
1756
+
1757
+ } else if (force === undefined || (force !== undefined && force === false)) {
1758
+ this.scrollingDivs["menu_scroller"].removeEvents();
1759
+
1760
+ jq("#header").removeClass("on");
1761
+ jq("#menu").removeClass("on");
1762
+ jq("#navbar").removeClass("on");
1763
+ jq("#content").removeClass("on");
1764
+ setTimeout(function() {
1765
+ jq("#menu").hide();
1766
+ }, 300); //lame I know
1767
+ }
1768
+ },
1769
+ /**
1770
+ * depricated
1771
+ ```
1772
+ $.ui.updateNavbar();//toggle it
1773
+ ```
1774
+ * @title $.ui.updateNavbar([force])
1775
+ * @api private
1776
+ */
1777
+ updateNavbar: function() {
1778
+ },
1779
+ /**
1780
+ * Updates the elements in the navbar
1781
+ ```
1782
+ $.ui.updateNavbarElements(elements);
1783
+ ```
1784
+ * @param {String|Object} Elements
1785
+ * @title $.ui.updateNavbarElements(Elements)
1786
+ */
1787
+ updateNavbarElements: function(elems) {
1788
+ var nb = jq("#navbar");
1789
+ if (elems === undefined || elems == null)
1790
+ return;
1791
+ if (typeof (elems) == "string")
1792
+ return nb.html(elems), null;
1793
+ nb.html("");
1794
+ for (var i = 0; i < elems.length; i++) {
1795
+ var node = elems[i].cloneNode(true);
1796
+ nb.append(node);
1797
+ }
1798
+ jq("#navbar a").data("ignore-pressed", "true").data("resetHistory", "true");
1799
+ },
1800
+ /**
1801
+ * Updates the elements in the header
1802
+ ```
1803
+ $.ui.updateHeaderElements(elements);
1804
+ ```
1805
+ * @param {String|Object} Elements
1806
+ * @title $.ui.updateHeaderElement(Elements)
1807
+ */
1808
+ updateHeaderElements: function(elems) {
1809
+ var nb = jq("#header");
1810
+ if (elems === undefined || elems == null)
1811
+ return;
1812
+ if (typeof (elems) == "string")
1813
+ return nb.html(elems), null;
1814
+ nb.html("");
1815
+ for (var i = 0; i < elems.length; i++) {
1816
+ var node = elems[i].cloneNode(true);
1817
+ nb.append(node);
1818
+ }
1819
+ },
1820
+
1821
+ /**
1822
+ * Updates the elements in the side menu
1823
+ ```
1824
+ $.ui.updateSideMenu(elements);
1825
+ ```
1826
+ * @param {String|Object} Elements
1827
+ * @title $.ui.updateSideMenu(Elements)
1828
+ */
1829
+ updateSideMenu: function(elems) {
1830
+ var that = this;
1831
+
1832
+ var nb = jq("#menu_scroller");
1833
+
1834
+ if (elems === undefined || elems == null)
1835
+ return;
1836
+ if (typeof (elems) == "string")
1837
+ return nb.html(elems), null;
1838
+ nb.html('');
1839
+ var close = document.createElement("a");
1840
+ close.className = "closebutton jqMenuClose";
1841
+ close.href = "javascript:;"
1842
+ close.onclick = function() {
1843
+ that.toggleSideMenu();
1844
+ };
1845
+ nb.append(close);
1846
+ var tmp = document.createElement("div");
1847
+ tmp.className = "jqMenuHeader";
1848
+ tmp.innerHTML = "Menu";
1849
+ nb.append(tmp);
1850
+ for (var i = 0; i < elems.length; i++) {
1851
+ var node = elems[i].cloneNode(true);
1852
+ if (elems[i].oldhash) {
1853
+ node.href = elems[i].oldhref;
1854
+ node.onclick = elems[i].oldonclick;
1855
+ }
1856
+ nb.append(node);
1857
+ }
1858
+ //Move the scroller to the top and hide it
1859
+ this.scrollingDivs['menu_scroller'].scrollTo({
1860
+ x: 0,
1861
+ y: 0
1862
+ }, "0");
1863
+ },
1864
+ /**
1865
+ * Set the title of the current panel
1866
+ ```
1867
+ $.ui.setTitle("new title");
1868
+ ```
1869
+
1870
+ * @param {String} value
1871
+ * @title $.ui.setTitle(value)
1872
+ */
1873
+ setTitle: function(val) {
1874
+ jq("#header #pageTitle").html(val);
1875
+ },
1876
+ /**
1877
+ * Override the text for the back button
1878
+ ```
1879
+ $.ui.setBackButtonText("GO...");
1880
+ ```
1881
+
1882
+ * @param {String} value
1883
+ * @title $.ui.setBackButtonText(value)
1884
+ */
1885
+ setBackButtonText: function(text) {
1886
+ if (this.backButtonText.length > 0)
1887
+ jq("#header #backButton").html(this.backButtonText);
1888
+ else
1889
+ jq("#header #backButton").html(text);
1890
+ },
1891
+ /**
1892
+ * Show the loading mask
1893
+ ```
1894
+ $.ui.showMask()
1895
+ $.ui.showMask(;Doing work')
1896
+ ```
1897
+
1898
+ * @param {String} [text]
1899
+ * @title $.ui.showMask(text);
1900
+ */
1901
+ showMask: function(text) {
1902
+ if (!text)
1903
+ text = "Loading Content";
1904
+ jq("#jQui_mask>h1").html(text);
1905
+ $am("jQui_mask").style.display = "block";
1906
+ },
1907
+ /**
1908
+ * Hide the loading mask
1909
+ * @title $.ui.hideMask();
1910
+ */
1911
+ hideMask: function() {
1912
+ $am("jQui_mask").style.display = "none";
1913
+ },
1914
+ /**
1915
+ * Load a content panel in a modal window. We set the innerHTML so event binding will not work.
1916
+ ```
1917
+ $.ui.showModal("#myDiv");
1918
+ ```
1919
+ * @param {String|Object} panel to show
1920
+ * @title $.ui.showModal();
1921
+ */
1922
+ showModal: function(id) {
1923
+ var that = this;
1924
+
1925
+ if ($am(id)) {
1926
+ //jq("#modalContainer").html('<div style="width:1px;height:1px;-webkit-transform:translate3d(0,0,0);float:right"></div>' + $am(id).childNodes[0].innerHTML + '');
1927
+ jq("#modalContainer").html($am(id).childNodes[0].innerHTML);
1928
+ jq('#modalContainer').append("<a href='javascript:;' onclick='$.ui.hideModal();' class='closebutton modalbutton'></a>");
1929
+ this.modalWindow.style.display = "block";
1930
+
1931
+ button = null;
1932
+ content = null;
1933
+ this.scrollingDivs['modal_container'].initEvents();
1934
+ this.scrollToTop('modal');
1935
+ }
1936
+
1937
+ },
1938
+ /**
1939
+ * Hide the modal window and remove the content
1940
+ ```
1941
+ $.ui.hideModal("#myDiv");
1942
+ ```
1943
+ * @title $.ui.hideModal();
1944
+ */
1945
+ hideModal: function() {
1946
+ $am("modalContainer").innerHTML = "";
1947
+ $am("jQui_modal").style.display = "none";
1948
+
1949
+ this.scrollingDivs['modal_container'].removeEvents();
1950
+ },
1951
+
1952
+ /**
1953
+ * Update the HTML in a content panel
1954
+ ```
1955
+ $.ui.updateContentDiv("#myDiv","This is the new content");
1956
+ ```
1957
+ * @param {String,Object} panel
1958
+ * @param {String} html to update with
1959
+ * @title $.ui.updateContentDiv(id,content);
1960
+ */
1961
+ updateContentDiv: function(id, content) {
1962
+ var el = $am(id);
1963
+ if (!el)
1964
+ return;
1965
+ if (el.getAttribute("scrolling") && el.getAttribute("scrolling").toLowerCase() == "no")
1966
+ el.innerHTML = content;
1967
+ else
1968
+ el.childNodes[0].innerHTML = content;
1969
+ },
1970
+ /**
1971
+ * Dynamically create a new panel on the fly. It wires events, creates the scroller, applies Android fixes, etc.
1972
+ ```
1973
+ $.ui.addContentDiv("myDiv","This is the new content","Title");
1974
+ ```
1975
+ * @param {String|Object} Element to add
1976
+ * @param {String} Content
1977
+ * @param {String} title
1978
+ * @title $.ui.addContentDiv(id,content,title);
1979
+ */
1980
+ addContentDiv: function(el, content, title, refresh, refreshFunc) {
1981
+ var myEl = $am(el);
1982
+ if (!myEl) {
1983
+ var newDiv = document.createElement("div");
1984
+ newDiv.id = el;
1985
+ newDiv.title = title;
1986
+ newDiv.innerHTML = content;
1987
+ } else {
1988
+ newDiv = myEl;
1989
+ }
1990
+ newDiv.className = "panel";
1991
+ var that = this;
1992
+
1993
+ myEl = null;
1994
+ that.addDivAndScroll(newDiv, refresh, refreshFunc);
1995
+ newDiv = null;
1996
+ return;
1997
+ },
1998
+ /**
1999
+ * Takes a div and sets up scrolling for it..
2000
+ ```
2001
+ $.ui.addDivAndScroll(object);
2002
+ ```
2003
+ * @param {Object} Element
2004
+ * @title $.ui.addDivAndScroll(element);
2005
+ * @api private
2006
+ */
2007
+ addDivAndScroll: function(tmp, refreshPull, refreshFunc) {
2008
+ var addScroller = true;
2009
+ if (tmp.getAttribute("scrolling") && tmp.getAttribute("scrolling").toLowerCase() == "no")
2010
+ addScroller = false;
2011
+ if (!addScroller) {
2012
+ this.content.appendChild(tmp);
2013
+ tmp = null;
2014
+ return;
2015
+ }
2016
+ //WE need to clone the div so we keep events
2017
+ var myDiv = tmp.cloneNode(false);
2018
+
2019
+
2020
+ tmp.title = null;
2021
+ tmp.id = null;
2022
+ tmp.removeAttribute("footer");
2023
+ tmp.removeAttribute("nav");
2024
+ jq(tmp).removeClass("panel");
2025
+ tmp.style.width = "100%";
2026
+ //tmp.style.height = "inherit";
2027
+
2028
+ myDiv.appendChild(tmp);
2029
+
2030
+ this.content.appendChild(myDiv);
2031
+
2032
+ this.selectBox.getOldSelects(myDiv.id);
2033
+ this.passwordBox.getOldPasswords(myDiv.id);
2034
+
2035
+ if (addScroller) {
2036
+ this.scrollingDivs[myDiv.id] = (jq(tmp).scroller({
2037
+ scrollBars: true,
2038
+ verticalScroll: true,
2039
+ horizontalScroll: false,
2040
+ vScrollCSS: "jqmScrollbar",
2041
+ refresh: false
2042
+ }));
2043
+ this.scrollingDivs[myDiv.id].removeEvents();
2044
+ }
2045
+
2046
+
2047
+ myDiv = null;
2048
+ tmp = null;
2049
+ },
2050
+
2051
+ /**
2052
+ * This has been depricated, as it was a design flaw on my end. People were updating segments of the panel and not the whole part. It's counter intuitive to have to call
2053
+ * $.ui.updateAnchors(object,reset) after each change.
2054
+ * This will be removed in 1.1
2055
+ * @title $.ui.updateAnchors(element,resetHistory);
2056
+ * @api private
2057
+ */
2058
+ updateAnchors: function(domEl, reset) {
2059
+ },
2060
+ /**
2061
+ * Scrolls a panel to the top
2062
+ ```
2063
+ $.ui.scrollToTop(id);
2064
+ ```
2065
+ * @param {String} id without hash
2066
+ * @title $.ui.scrollToTop(id);
2067
+ */
2068
+ scrollToTop: function(id) {
2069
+ if (this.scrollingDivs[id]) {
2070
+ this.scrollingDivs[id].scrollTo({
2071
+ x: 0,
2072
+ y: 0
2073
+ }, 0);
2074
+ }
2075
+ },
2076
+ /**
2077
+ * Scrolls all panels to the top and fixes position when orientation changes
2078
+ ```
2079
+ $.ui.updateOrientation(event);
2080
+ ```
2081
+ * @param {Event} event
2082
+ * @title $.ui.updateOrientation(event);
2083
+ * @api private
2084
+ */
2085
+ updateOrientation: function(event) {
2086
+ for (var j in this.scrollingDivs) {
2087
+ if (typeof (this.scrollingDivs[j]) !== "function")
2088
+ this.scrollToTop(j);
2089
+ }
2090
+ },
2091
+
2092
+ /**
2093
+ * This is used when a transition fires to do helper events. We check to see if we need to change the nav menus, footer, and fire
2094
+ * the load/onload functions for panels
2095
+ ```
2096
+ $.ui.parsePanelFunctions(currentDiv,oldDiv);
2097
+ ```
2098
+ * @param {Object} current div
2099
+ * @param {Object} old div
2100
+ * @title $.ui.parsePanelFunctions(currentDiv,oldDiv);
2101
+ * @api private
2102
+ */
2103
+ parsePanelFunctions: function(what, oldDiv) {
2104
+ var that = this;
2105
+ var hasFooter = what.getAttribute("data-footer");
2106
+ var hasHeader = what.getAttribute("data-header");
2107
+ window.setTimeout(function() {
2108
+ if (hasFooter && hasFooter.toLowerCase() == "none") {
2109
+ that.toggleNavMenu(false);
2110
+ } else {
2111
+ that.toggleNavMenu(true);
2112
+ }
2113
+ if (hasFooter && that.customFooter != hasFooter) {
2114
+ that.customFooter = hasFooter;
2115
+ that.updateNavbarElements(jq("#" + hasFooter).children());
2116
+ } else if (hasFooter != that.customFooter) {
2117
+ if (that.customFooter)
2118
+ that.updateNavbarElements(that.defaultFooter);
2119
+ that.customFooter = false;
2120
+ }
2121
+
2122
+
2123
+ if (hasHeader && that.customHeader != hasHeader) {
2124
+ that.customHeader = hasHeader;
2125
+ that.updateHeaderElements(jq("#" + hasHeader).children());
2126
+ } else if (hasHeader != that.customHeader) {
2127
+ if (that.customHeader)
2128
+ {
2129
+ that.updateHeaderElements(that.defaultHeader);
2130
+ that.setTitle(that.activeDiv.title);
2131
+ }
2132
+ that.customHeader = false;
2133
+ }
2134
+
2135
+ //Load inline footers
2136
+ var inlineFooters = $(what).find("footer");
2137
+ if (inlineFooters.length > 0)
2138
+ {
2139
+ that.customFooter = what.id;
2140
+ that.updateNavbarElements(inlineFooters.children());
2141
+ }
2142
+ //load inline headers
2143
+ var inlineHeader = $(what).find("header");
2144
+
2145
+
2146
+ if (inlineHeader.length > 0)
2147
+ {
2148
+ that.customHeader = what.id;
2149
+ that.updateHeaderElements(inlineHeader.children());
2150
+ }
2151
+ //check if the panel has a footer
2152
+ if (what.getAttribute("data-tab")) { //Allow the dev to force the footer menu
2153
+
2154
+ jq("#navbar a").removeClass("selected");
2155
+ jq("#navbar #" + what.getAttribute("data-tab")).addClass("selected");
2156
+ }
2157
+ var hasMenu = what.getAttribute("data-nav");
2158
+ if (hasMenu && that.customMenu != hasMenu) {
2159
+ that.customMenu = hasMenu;
2160
+ that.updateSideMenu(jq("#" + hasMenu).children());
2161
+ } else if (hasMenu != that.customMenu) {
2162
+ if (that.customMenu)
2163
+ that.updateSideMenu(that.defaultMenu);
2164
+ that.customMenu = false;
2165
+ }
2166
+
2167
+ }, 10);
2168
+
2169
+
2170
+
2171
+ var fnc = what.getAttribute("data-load");
2172
+ if (typeof fnc == "string" && window[fnc]) {
2173
+ window[fnc](what);
2174
+ }
2175
+ if (oldDiv) {
2176
+ fnc = oldDiv.getAttribute("data-unload");
2177
+ if (typeof fnc == "string" && window[fnc]) {
2178
+ window[fnc](oldDiv);
2179
+ }
2180
+ }
2181
+ if (this.menu.style.display == "block")
2182
+ this.toggleSideMenu(); //Close on phones to prevent orientation change bug.
2183
+
2184
+ },
2185
+ /**
2186
+ * Helper function that parses a contents html for any script tags and either adds them or executes the code
2187
+ * @api private
2188
+ */
2189
+ parseScriptTags: function(div) {
2190
+ if (!div)
2191
+ return;
2192
+ var scripts = div.getElementsByTagName("script");
2193
+ div = null;
2194
+ for (var i = 0; i < scripts.length; i++) {
2195
+ if (scripts[i].src.length > 0 && !that.remoteJSPages[scripts[i].src]) {
2196
+ var doc = document.createElement("script");
2197
+ doc.type = scripts[i].type;
2198
+ doc.src = scripts[i].src;
2199
+ document.getElementsByTagName('head')[0].appendChild(doc);
2200
+ that.remoteJSPages[scripts[i].src] = 1;
2201
+ doc = null;
2202
+ } else {
2203
+ window.eval(scripts[i].innerHTML);
2204
+ }
2205
+ }
2206
+ },
2207
+ /**
2208
+ * This is called to initiate a transition or load content via ajax.
2209
+ * We can pass in a hash+id or URL and then we parse the panel for additional functions
2210
+ ```
2211
+ $.ui.loadContent("#main",false,false,"up");
2212
+ ```
2213
+ * @param {String} target
2214
+ * @param {Boolean} newtab (resets history)
2215
+ * @param {Boolean} go back (initiate the back click)
2216
+ * @param {String} transition
2217
+ * @title $.ui.loadContent(target,newTab,goBack,transition);
2218
+ * @api public
2219
+ */
2220
+ loadContent: function(target, newTab, back, transition, anchor) {
2221
+
2222
+ if (this.doingTransition)
2223
+ return;
2224
+
2225
+
2226
+ what = null;
2227
+ var that = this;
2228
+ that.hideMask();
2229
+ var loadAjax = true;
2230
+ if (target.indexOf("#") == -1) {
2231
+ var urlHash = "url" + crc32(target); //Ajax urls
2232
+ if ($am(urlHash)) {
2233
+
2234
+ //ajax div already exists. Let's see if we should be refreshing it.
2235
+ loadAjax = false;
2236
+ if (anchor.getAttribute("data-refresh-ajax") === 'true' || (anchor.refresh && anchor.refresh === true)||this.isAjaxApp) {
2237
+ loadAjax = true;
2238
+ } else
2239
+ target = "#" + urlHash;
2240
+ }
2241
+ }
2242
+
2243
+ if (target.indexOf("#") == -1 && anchor && loadAjax) {
2244
+
2245
+ // XML Request
2246
+ if (this.activeDiv.id == "jQui_ajax" && target == this.ajaxUrl)
2247
+ return;
2248
+ if (target.indexOf("http") == -1)
2249
+ target = AppMobi.webRoot + target;
2250
+
2251
+ var xmlhttp = new XMLHttpRequest();
2252
+ xmlhttp.onreadystatechange = function() {
2253
+ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
2254
+ this.doingTransition = false;
2255
+
2256
+ var doReturn = false;
2257
+
2258
+ //Here we check to see if we are retaining the div, if so update it
2259
+ if ($am(urlHash) !== undefined) {
2260
+ that.updateContentDiv(urlHash, xmlhttp.responseText);
2261
+ $am(urlHash).title = anchor.title ? anchor.title : target;
2262
+ } else if (anchor.getAttribute("data-persist-ajax")||that.isAjaxApp) {
2263
+
2264
+ var refresh = (anchor.getAttribute("data-pull-scroller") === 'true') ? true : false;
2265
+ refreshFunction = refresh ?
2266
+ function() {
2267
+ anchor.refresh = true;
2268
+ that.loadContent(target, newTab, back, transition, anchor);
2269
+ anchor.refresh = false;
2270
+ } : null
2271
+ that.addContentDiv(urlHash, xmlhttp.responseText, refresh, refreshFunction);
2272
+ $am(urlHash).title = anchor.title ? anchor.title : target;
2273
+ } else {
2274
+ that.updateContentDiv("jQui_ajax", xmlhttp.responseText);
2275
+ $am("jQui_ajax").title = anchor.title ? anchor.title : target;
2276
+ that.loadContent("#jQui_ajax", newTab, back);
2277
+ doReturn = true;
2278
+ }
2279
+ //Let's load the content now.
2280
+ //We need to check for any script tags and handle them
2281
+ var div = document.createElement("div");
2282
+ div.innerHTML = xmlhttp.responseText;
2283
+ that.parseScriptTags(div);
2284
+ if (doReturn)
2285
+ return;
2286
+
2287
+ return that.loadContent("#" + urlHash);
2288
+
2289
+ }
2290
+ };
2291
+ ajaxUrl = target;
2292
+ var newtarget = this.useAjaxCacheBuster ? target + (target.split('?')[1] ? '&' : '?') + "cache=" + Math.random() * 10000000000000000 : target;
2293
+ xmlhttp.open("GET", newtarget, true);
2294
+ xmlhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
2295
+ xmlhttp.send();
2296
+ // show Ajax Mask
2297
+ if(this.showLoading)
2298
+ this.showMask();
2299
+ return;
2300
+ } else {
2301
+ // load a div
2302
+
2303
+ what = target.replace("#", "");
2304
+
2305
+ var slashIndex = what.indexOf('/');
2306
+ var hashLink = "";
2307
+ if (slashIndex != -1) {
2308
+ // Ignore everything after the slash for loading
2309
+ hashLink = what.substr(slashIndex);
2310
+ what = what.substr(0, slashIndex);
2311
+ }
2312
+
2313
+ what = $am(what);
2314
+
2315
+ if (!what)
2316
+ throw ("Target: " + target + " was not found");
2317
+ if (what == this.activeDiv && !back)
2318
+ return;
2319
+
2320
+ if (what.getAttribute("data-modal") == "true" || what.getAttribute("modal") == "true") {
2321
+ return this.showModal(what.id);
2322
+ }
2323
+
2324
+
2325
+
2326
+ this.transitionType = transition;
2327
+ var oldDiv = this.activeDiv;
2328
+ var currWhat = what;
2329
+
2330
+
2331
+ if (oldDiv == currWhat) //prevent it from going to itself
2332
+ return;
2333
+
2334
+ if (newTab) {
2335
+
2336
+ this.history = [];
2337
+ if(("#" + this.firstDiv.id)!=target){
2338
+ this.history.push({
2339
+ target: "#" + this.firstDiv.id,
2340
+ transition: transition
2341
+ });
2342
+ }
2343
+ } else if (!back) {
2344
+ this.history.push({
2345
+ target: previousTarget,
2346
+ transition: transition
2347
+ });
2348
+
2349
+ }
2350
+ window.history.pushState(what.id, what.id, startPath + '#' + what.id + hashLink);
2351
+ $(window).trigger("hashchange", {newUrl: startPath + '#' + what.id + hashLink,oldURL: startPath + "#" + this.activeDiv.id});
2352
+
2353
+ previousTarget = '#' + what.id + hashLink;
2354
+
2355
+ if (this.resetScrollers && this.scrollingDivs[what.id]) {
2356
+ this.scrollingDivs[what.id].scrollTo({
2357
+ x: 0,
2358
+ y: 0
2359
+ });
2360
+ }
2361
+ $(what).addClass("active");
2362
+
2363
+ what.style.display = "block";
2364
+ that.doingTransition = true;
2365
+ if (that.availableTransitions[transition])
2366
+ that.availableTransitions[transition].call(that, oldDiv, currWhat, back);
2367
+ else
2368
+ that.availableTransitions['default'].call(that, oldDiv, currWhat, back);
2369
+
2370
+
2371
+
2372
+ this.activeDiv = what;
2373
+
2374
+ if (this.scrollingDivs[this.activeDiv.id]) {
2375
+ this.scrollingDivs[this.activeDiv.id].initEvents();
2376
+ }
2377
+ if (this.scrollingDivs[oldDiv.id]) {
2378
+ this.scrollingDivs[oldDiv.id].removeEvents();
2379
+ }
2380
+ //Let's check if it has a function to run to update the data
2381
+
2382
+
2383
+
2384
+ setTimeout(function(){
2385
+ that.parsePanelFunctions(what, oldDiv);
2386
+ },300);
2387
+ setTimeout(function(){
2388
+
2389
+ if (back) {
2390
+ if (that.history.length > 0) {
2391
+ var val = that.history[that.history.length - 1];
2392
+
2393
+ var el = $am(val.target.replace("#", ""));
2394
+ that.setBackButtonText(el.title)
2395
+ }
2396
+ } else if (that.activeDiv.title)
2397
+ that.setBackButtonText(that.activeDiv.title)
2398
+ else
2399
+ that.setBackButtonText("Back");
2400
+ if (what.title) {
2401
+ that.setTitle(what.title);
2402
+ }
2403
+ if (newTab) {
2404
+ that.setBackButtonText(that.firstDiv.title)
2405
+ }
2406
+
2407
+ //Update the back buttons
2408
+ if (that.history.length == 0) {
2409
+ jq("#header #backButton").css("visibility","hidden");
2410
+ that.history = [];
2411
+ } else if (that.showBackbutton){
2412
+ jq("#header #backButton").css("visibility","visible");
2413
+ }
2414
+ },370);
2415
+ window.scrollTo(1, 1);
2416
+
2417
+ }
2418
+ },
2419
+
2420
+ /**
2421
+ * This is callled when you want to launch jqUi. If autoLaunch is set to true, it gets called on DOMContentLoaded.
2422
+ * If autoLaunch is set to false, you can manually invoke it.
2423
+ ```
2424
+ $.ui.autoLaunch=false;
2425
+ $.ui.launch();
2426
+ ```
2427
+ * @title $.ui.launch();
2428
+ */
2429
+ launch: function() {
2430
+
2431
+ if (this.hasLaunched == false || this.launchCompleted) {
2432
+ this.hasLaunched = true;
2433
+ return;
2434
+ }
2435
+ this.isAppMobi = (window.AppMobi && typeof (AppMobi) == "object" && AppMobi.app !== undefined) ? true : false;
2436
+ var that = this;
2437
+ this.viewportContainer = jq("#jQUi");
2438
+ this.navbar = $am("navbar");
2439
+ this.content = $am("content");
2440
+ this.header = $am("header");
2441
+ this.menu = $am("menu");
2442
+ if (this.viewportContainer.length == 0) {
2443
+ var container = document.createElement("div");
2444
+ container.id = "jQUi";
2445
+ var body = document.body;
2446
+ while (body.firstChild) {
2447
+ container.appendChild(body.firstChild);
2448
+ }
2449
+ jq(document.body).prepend(container);
2450
+ this.viewportContainer = jq("#jQUi");
2451
+ }
2452
+ if (!this.navbar) {
2453
+ this.navbar = document.createElement("div");
2454
+ this.navbar.id = "navbar";
2455
+ this.navbar.style.cssText = "display:none";
2456
+ this.viewportContainer.append(this.navbar);
2457
+ }
2458
+ if (!this.header) {
2459
+ this.header = document.createElement("div");
2460
+ this.header.id = "header";
2461
+ this.viewportContainer.prepend(this.header);
2462
+ }
2463
+ if (!this.menu) {
2464
+ this.menu = document.createElement("div");
2465
+ this.menu.id = "menu";
2466
+ this.menu.style.overflow = "hidden";
2467
+ this.menu.innerHTML = "<div id='menu_scroller'></div>";
2468
+ this.viewportContainer.append(this.menu);
2469
+ this.scrollingDivs["menu_scroller"] = jq("#menu_scroller").scroller({
2470
+ scrollBars: true,
2471
+ verticalScroll: true,
2472
+ vScrollCSS: "jqmScrollbar"
2473
+ });
2474
+ }
2475
+
2476
+
2477
+ if (!this.content) {
2478
+ this.content = document.createElement("div");
2479
+ this.content.id = "content";
2480
+ this.viewportContainer.append(this.content);
2481
+ }
2482
+ this.header.innerHTML = '<a id="backButton" href="javascript:;"></a> <h1 id="pageTitle"></h1>' + this.header.innerHTML;
2483
+ this.backButton = $am("backButton");
2484
+ this.backButton.className = "button";
2485
+
2486
+ jq(document).on("click", "#backButton", function() {
2487
+ that.goBack();
2488
+ });
2489
+ this.backButton.style.visibility = "hidden";
2490
+ this.addContentDiv("jQui_ajax", "");
2491
+ var maskDiv = document.createElement("div");
2492
+ maskDiv.id = "jQui_mask";
2493
+ maskDiv.className = "ui-loader";
2494
+ maskDiv.innerHTML = "<span class='ui-icon ui-icon-loading spin'></span><h1>Loading Content</h1>";
2495
+ maskDiv.style.zIndex = 20000;
2496
+ maskDiv.style.display = "none";
2497
+ document.body.appendChild(maskDiv);
2498
+ var modalDiv = document.createElement("div");
2499
+ modalDiv.id = "jQui_modal";
2500
+
2501
+ this.viewportContainer.append(modalDiv);
2502
+ modalDiv.appendChild(jq("<div id='modalContainer'></div>").get());
2503
+ this.scrollingDivs['modal_container'] = jq("#modalContainer").scroller({
2504
+ scrollBars: true,
2505
+ vertical: true,
2506
+ vScrollCSS: "jqmScrollbar"
2507
+ });
2508
+
2509
+ this.modalWindow = modalDiv;
2510
+ var defer = [];
2511
+ var contentDivs = this.viewportContainer.get().querySelectorAll(".panel");
2512
+ for (var i = 0; i < contentDivs.length; i++) {
2513
+ var el = contentDivs[i];
2514
+ var tmp = el;
2515
+ var id;
2516
+ if (el.parentNode && el.parentNode.id != "content") {
2517
+ el.parentNode.removeChild(el);
2518
+ var id = el.id;
2519
+ this.addDivAndScroll(tmp);
2520
+ if (tmp.getAttribute("selected"))
2521
+ this.firstDiv = $am(id);
2522
+ } else if (!el.parsedContent) {
2523
+ el.parsedContent = 1;
2524
+ el.parentNode.removeChild(el);
2525
+ var id = el.id;
2526
+ this.addDivAndScroll(tmp);
2527
+ if (tmp.getAttribute("selected"))
2528
+ this.firstDiv = $am(id);
2529
+ }
2530
+ if (el.getAttribute("data-defer")){
2531
+ defer[id] = el.getAttribute("data-defer");
2532
+ defer.length++;
2533
+ }
2534
+ el = null;
2535
+ }
2536
+ if(!this.firstDiv)
2537
+ this.firstDiv=$("#content").children().get(0);
2538
+ contentDivs = null;
2539
+ var loadingDefer=false;
2540
+ var toLoad=defer.length;
2541
+ if(toLoad>0){
2542
+ loadingDefer=true;
2543
+ var loaded=0;
2544
+ for (var j in defer) {
2545
+ (function(j) {
2546
+ jq.ajax({url:AppMobi.webRoot + defer[j], success:function(data) {
2547
+ if (data.length == 0)
2548
+ return;
2549
+ $.ui.updateContentDiv(j, data);
2550
+ that.parseScriptTags(jq(j).get());
2551
+ loaded++;
2552
+ if(loaded>=toLoad){
2553
+ $(document).trigger("defer:loaded");
2554
+ loadingDefer=false;
2555
+
2556
+ }
2557
+ },error:function(msg){
2558
+ //still trigger the file as being loaded to not block jq.ui.ready
2559
+ console.log("Error with deferred load "+AppMobi.webRoot+defer[j])
2560
+ loaded++;
2561
+ if(loaded>=toLoad){
2562
+ $(document).trigger("defer:loaded");
2563
+ loadingDefer=false;
2564
+ }
2565
+ }});
2566
+ })(j);
2567
+ }
2568
+ }
2569
+ if (this.firstDiv) {
2570
+
2571
+ var that = this;
2572
+ // Fix a bug in iOS where translate3d makes the content blurry
2573
+ this.activeDiv = this.firstDiv;
2574
+
2575
+ //window.setTimeout(function() {
2576
+ var loadFirstDiv=function(){
2577
+ //activeDiv = firstDiv;
2578
+ if (defaultHash.length > 0 && that.loadDefaultHash&&defaultHash!=("#"+that.firstDiv.id))
2579
+ {
2580
+
2581
+ that.activeDiv=$(defaultHash).get();
2582
+ jq("#header #backButton").css("visibility","visible");
2583
+ that.setBackButtonText(that.activeDiv.title)
2584
+ that.history=[{target:"#"+that.firstDiv.id}]; //Reset the history to the first div
2585
+ }
2586
+ else
2587
+ previousTarget="#"+that.activeDiv.id;
2588
+ if (that.scrollingDivs[that.activeDiv.id]) {
2589
+ that.scrollingDivs[that.activeDiv.id].initEvents();
2590
+ }
2591
+ that.activeDiv.style.display = "block";
2592
+
2593
+
2594
+ if (that.activeDiv.title)
2595
+ that.setTitle(that.activeDiv.title);
2596
+ that.parsePanelFunctions(that.activeDiv);
2597
+ //Load the default hash
2598
+
2599
+ that.history=[{target:"#"+that.firstDiv.id}]; //Reset the history to the first div
2600
+ modalDiv = null;
2601
+ maskDiv = null;
2602
+ that.launchCompleted = true;
2603
+
2604
+ if(jq("#navbar a").length>0){
2605
+ jq("#navbar a").data("ignore-pressed", "true").data("resetHistory", "true");
2606
+ that.defaultFooter = jq("#navbar").children();
2607
+ that.updateNavbarElements(that.defaultFooter);
2608
+ }
2609
+ var firstMenu = jq("nav").get();
2610
+ if(firstMenu){
2611
+ that.defaultMenu = jq(firstMenu).children();
2612
+ that.updateSideMenu(that.defaultMenu);
2613
+ }
2614
+ that.defaultHeader = jq("#header").children();
2615
+ jq(document).trigger("jq.ui.ready");
2616
+ jq("#splashscreen").remove();
2617
+ };
2618
+ if(loadingDefer){
2619
+ $(document).one("defer:loaded",loadFirstDiv);
2620
+ }
2621
+ else
2622
+ loadFirstDiv();
2623
+ }
2624
+
2625
+ },
2626
+
2627
+ noTransition: function(oldDiv, currDiv, back) {
2628
+ oldDiv.style.display = "block";
2629
+ currDiv.style.display = "block";
2630
+ var that = this
2631
+ if (back) {
2632
+ that.css3animate(currDiv, {
2633
+ x: "0%",
2634
+ time: "1ms"
2635
+ });
2636
+ that.css3animate(oldDiv, {
2637
+ x: 0,
2638
+ time: "1ms"
2639
+ });
2640
+
2641
+ } else {
2642
+
2643
+ that.css3animate(oldDiv, {
2644
+ x: 0,
2645
+ y: 0,
2646
+ time: "1ms"
2647
+ });
2648
+ that.css3animate(currDiv, {
2649
+ x: "0%",
2650
+ time: "1ms"
2651
+ });
2652
+ }
2653
+ that.finishTransition(oldDiv);
2654
+ currDiv.style.zIndex = 2;
2655
+ oldDiv.style.zIndex = 1;
2656
+ $(oldDiv).removeClass('active');
2657
+ },
2658
+
2659
+ /**
2660
+ * This must be called at the end of every transition to hide the old div and reset the doingTransition variable
2661
+ *
2662
+ * @param {Object} Div that transitioned out
2663
+ * @title $.ui.finishTransition(oldDiv)
2664
+ */
2665
+ finishTransition: function(oldDiv) {
2666
+
2667
+ oldDiv.style.display = 'none';
2668
+ this.doingTransition = false;
2669
+
2670
+ }
2671
+ /**
2672
+ * END
2673
+ * @api private
2674
+ */
2675
+ };
2676
+
2677
+ function $am(el) {
2678
+ el = el.indexOf("#") == -1 ? "#" + el : el;
2679
+ return jq(el).get(0);
2680
+ }
2681
+
2682
+ var table = "00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D"; /* Number */
2683
+ var crc32 = function( /* String */str, /* Number */crc) {
2684
+ if (crc == undefined)
2685
+ crc = 0;
2686
+ var n = 0; //a number between 0 and 255
2687
+ var x = 0; //an hex number
2688
+ crc = crc ^ (-1);
2689
+ for (var i = 0, iTop = str.length; i < iTop; i++) {
2690
+ n = (crc ^ str.charCodeAt(i)) & 0xFF;
2691
+ x = "0x" + table.substr(n * 9, 8);
2692
+ crc = (crc >>> 8) ^ x;
2693
+ }
2694
+ return crc ^ (-1);
2695
+ };
2696
+
2697
+
2698
+ $.ui = new ui;
2699
+ })(jq);
2700
+
2701
+ //The following functions are utilitiy functions for jqUi. They are not apart of the base class, but help with locking the page scroll,
2702
+ //input box issues, remove the address bar on iOS and android, etc
2703
+ (function() {
2704
+ var jQUi;
2705
+
2706
+ //Check to see if any <nav> items are found. If so, add the CSS classes
2707
+ jq(document).ready(function() {
2708
+ if (jq("nav").length > 0) {
2709
+ jq("#jQUi #header").addClass("hasMenu");
2710
+ jq("#jQUi #content").addClass("hasMenu");
2711
+ jq("#jQUi #navbar").addClass("hasMenu");
2712
+ }
2713
+ jQUi = jq("#jQUi");
2714
+ setTimeout(function(){
2715
+ hideAddressBar();
2716
+ },100);
2717
+ });
2718
+
2719
+ document.addEventListener("appMobi.device.ready", function() { //in AppMobi, we need to undo the height stuff since it causes issues.
2720
+ setTimeout(function() {
2721
+ jQUi.css("height", "100%"), document.body.style.height = "100%";
2722
+ document.documentElement.style.minHeight = window.innerHeight;
2723
+ }, 300);
2724
+ });
2725
+
2726
+
2727
+ window.addEventListener("orientationchange", function(e) {
2728
+ jq.ui.updateOrientation()
2729
+ window.setTimeout(function() {
2730
+ hideAddressBar();
2731
+ }, 200);
2732
+ }, false);
2733
+
2734
+ if (jq.os.android)
2735
+ {
2736
+ window.addEventListener("resize", function(e) {
2737
+ window.scrollTo(0,1);
2738
+ jq.ui.updateOrientation();
2739
+ if(document.body.clientWidth>=700)
2740
+ $.ui.toggleSideMenu(false);
2741
+ window.setTimeout(function() {
2742
+ hideAddressBar();
2743
+ }, 100);
2744
+ }, false);
2745
+ }
2746
+
2747
+
2748
+ function hideAddressBar() {
2749
+ if (jq.os.desktop)
2750
+ return jQUi.css("height", "100%");
2751
+ if (jq.os.android) {
2752
+ window.scrollTo(1, 1);
2753
+ if (document.documentElement.scrollHeight < window.outerHeight / window.devicePixelRatio)
2754
+ jQUi.css("height", (window.outerHeight / window.devicePixelRatio) + 'px');
2755
+ }
2756
+ else {
2757
+ document.documentElement.style.height = "5000px";
2758
+
2759
+ window.scrollTo(0, 1);
2760
+ document.documentElement.style.height = window.innerHeight + "px";
2761
+ jQUi.css("height", window.innerHeight + "px");
2762
+ }
2763
+ }
2764
+ //The following is based on Cubiq.org - iOS no click delay. We use this to capture events to input boxes to fix Android...and fix iOS ;)
2765
+ //We had to make a lot of fixes to allow access to input elements on android, etc.
2766
+ function NoClickDelay(el) {
2767
+ if (typeof (el) === "string")
2768
+ el = document.getElementById(el);
2769
+ el.addEventListener('touchstart', this, true);
2770
+ }
2771
+ var prevClickField;
2772
+ var prevPanel;
2773
+ var prevField;
2774
+ NoClickDelay.prototype = {
2775
+ dX: 0,
2776
+ dY: 0,
2777
+ cX: 0,
2778
+ cY: 0,
2779
+ handleEvent: function(e) {
2780
+ switch (e.type) {
2781
+ case 'touchstart':
2782
+ this.onTouchStart(e);
2783
+ break;
2784
+ case 'touchmove':
2785
+ this.onTouchMove(e);
2786
+ break;
2787
+ case 'touchend':
2788
+ this.onTouchEnd(e);
2789
+ break;
2790
+ }
2791
+ },
2792
+
2793
+ onTouchStart: function(e) {
2794
+
2795
+ this.dX = e.touches[0].pageX;
2796
+ this.dY = e.touches[0].pageY;
2797
+
2798
+ var theTarget = e.target;
2799
+ if (theTarget.nodeType == 3)
2800
+ theTarget = theTarget.parentNode;
2801
+
2802
+ if(prevField){
2803
+ prevField.blur();
2804
+ prevField=null;
2805
+ }
2806
+ if(prevPanel){
2807
+ //prevField.blur();
2808
+ prevPanel.css("-webkit-transform","translate3d(0px,0px,0px)");
2809
+ prevPanel.css("left","0");
2810
+ prevField=null;
2811
+ prevPanel=null;
2812
+ }
2813
+
2814
+ var tagname = theTarget.tagName.toLowerCase();
2815
+ var type=theTarget.type||"";
2816
+ if((tagname=="a"&& theTarget.href.indexOf("tel:")===0)||((tagname=="input")||tagname=="textarea"||tagname=="select")){
2817
+ prevField=theTarget;
2818
+ if(jq.os.android&&$.ui.fixAndroidInputs){
2819
+ theTarget.focus();
2820
+ prevField=theTarget;
2821
+ prevPanel=$(theTarget).closest(".panel");
2822
+ prevPanel.css("left","-100%");
2823
+ prevPanel.css("-webkit-transition-duration","0ms");
2824
+ prevPanel.css("-webkit-transform","translate3d(100%,0px,0px)");
2825
+ prevPanel.css("position","absolute");
2826
+ return;
2827
+ }
2828
+ }
2829
+ else
2830
+ e.preventDefault();
2831
+ this.moved = false;
2832
+ document.addEventListener('touchmove', this, true);
2833
+ document.addEventListener('touchend', this, true);
2834
+ },
2835
+
2836
+ onTouchMove: function(e) {
2837
+ this.moved = true;
2838
+ this.cX = e.touches[0].pageX - this.dX;
2839
+ this.cY = e.touches[0].pageY - this.dY;
2840
+ // e.preventDefault();
2841
+ },
2842
+
2843
+ onTouchEnd: function(e) {
2844
+
2845
+ document.removeEventListener('touchmove', this, false);
2846
+ document.removeEventListener('touchend', this, false);
2847
+
2848
+ if ((!jq.os.blackberry && !this.moved) || (jq.os.blackberry && (Math.abs(this.cX) < 5 || Math.abs(this.cY) < 5))) {
2849
+ var theTarget = e.target;
2850
+ if (theTarget.nodeType == 3)
2851
+ theTarget = theTarget.parentNode;
2852
+
2853
+ var theEvent = document.createEvent('MouseEvents');
2854
+ theEvent.initEvent('click', true, true);
2855
+ theTarget.dispatchEvent(theEvent);
2856
+
2857
+ }
2858
+ prevClickField = null;
2859
+ this.dX = this.cX = this.cY = this.dY = 0;
2860
+ }
2861
+ };
2862
+
2863
+
2864
+
2865
+ jq(document).ready(function() {
2866
+ document.body.addEventListener('touchmove', function(e) {
2867
+ e.preventDefault();
2868
+ e.stopPropagation();
2869
+ window.scrollTo(1, 1);
2870
+ }, false);
2871
+ if (!jq.os.desktop)
2872
+ new NoClickDelay(document.getElementById("jQUi"));
2873
+
2874
+ document.getElementById("jQUi").addEventListener("click", function(e) {
2875
+
2876
+ var theTarget = e.target;
2877
+ if (theTarget.nodeType == 3)
2878
+ theTarget = theTarget.parentNode;
2879
+ if (checkAnchorClick(theTarget)) {
2880
+ e.preventDefault();
2881
+ return false;
2882
+ }
2883
+ }, true);
2884
+
2885
+ jq("#navbar").on("click", "a", function(e) {
2886
+ jq("#navbar a").removeClass("selected");
2887
+ setTimeout(function() {
2888
+ $(e.target).addClass("selected");
2889
+ }, 10);
2890
+ });
2891
+ });
2892
+
2893
+ function checkAnchorClick(theTarget) {
2894
+ var parent = false;
2895
+ if (theTarget.tagName.toLowerCase() != "a" && theTarget.parentNode)
2896
+ parent = true, theTarget = theTarget.parentNode; //let's try the parent so <a href="#foo"><img src="whatever.jpg"></a> will work
2897
+ if (theTarget.tagName.toLowerCase() == "a") {
2898
+ if (theTarget.href.toLowerCase().indexOf("javascript:") !== -1 || theTarget.getAttribute("data-ignore")) {
2899
+ return false;
2900
+ }
2901
+
2902
+ if (theTarget.onclick && !jq.os.desktop) {
2903
+ theTarget.onclick();
2904
+ }
2905
+
2906
+ if(theTarget.href.indexOf("tel:")===0)
2907
+ return false;
2908
+ if (theTarget.hash.indexOf("#") === -1 && theTarget.target.length > 0)
2909
+ {
2910
+
2911
+ if (theTarget.href.toLowerCase().indexOf("javascript:") != 0) {
2912
+ if (jq.ui.isAppMobi)
2913
+ AppMobi.device.launchExternal(theTarget.href);
2914
+ else if (!jq.os.desktop)
2915
+ brokerClickEventMobile(theTarget);
2916
+ else
2917
+ window.open(theTarget);
2918
+ return true;
2919
+ }
2920
+ return false;
2921
+ }
2922
+ if ((theTarget.href.indexOf("#") !== -1 && theTarget.hash.length == 0) || theTarget.href.length == 0)
2923
+ return true;
2924
+
2925
+ var mytransition = theTarget.getAttribute("data-transition");
2926
+ var resetHistory = theTarget.getAttribute("data-resetHistory");
2927
+
2928
+ resetHistory = resetHistory && resetHistory.toLowerCase() == "true" ? true : false;
2929
+
2930
+ var href = theTarget.hash.length > 0 ? theTarget.hash : theTarget.href;
2931
+ jq.ui.loadContent(href, resetHistory, 0, mytransition, theTarget);
2932
+ return true;
2933
+ }
2934
+ }
2935
+ function brokerClickEventMobile(theTarget) {
2936
+ if (jq.os.desktop)
2937
+ return;
2938
+ var clickevent = document.createEvent('Event');
2939
+ clickevent.initEvent('click', true, false);
2940
+ theTarget.target = "_blank";
2941
+ theTarget.dispatchEvent(clickevent);
2942
+ }
2943
+ })();
2944
+
2945
+ //Touch events are from zepto/touch.js
2946
+
2947
+ (function($) {
2948
+ var touch = {}, touchTimeout;
2949
+
2950
+ function parentIfText(node) {
2951
+ return 'tagName' in node ? node : node.parentNode;
2952
+ }
2953
+
2954
+ function swipeDirection(x1, x2, y1, y2) {
2955
+ var xDelta = Math.abs(x1 - x2), yDelta = Math.abs(y1 - y2);
2956
+ if (xDelta >= yDelta) {
2957
+ return (x1 - x2 > 0 ? 'Left' : 'Right');
2958
+ } else {
2959
+ return (y1 - y2 > 0 ? 'Up' : 'Down');
2960
+ }
2961
+ }
2962
+
2963
+ var longTapDelay = 750;
2964
+ function longTap() {
2965
+ if (touch.last && (Date.now() - touch.last >= longTapDelay)) {
2966
+ touch.el.trigger('longTap');
2967
+ touch = {};
2968
+ }
2969
+ }
2970
+ $(document).ready(function() {
2971
+ $(document.body).bind('touchstart', function(e) {
2972
+ var now = Date.now(), delta = now - (touch.last || now);
2973
+ touch.el = $(parentIfText(e.touches[0].target));
2974
+ touchTimeout && clearTimeout(touchTimeout);
2975
+ touch.x1 = e.touches[0].pageX;
2976
+ touch.y1 = e.touches[0].pageY;
2977
+ if (delta > 0 && delta <= 250)
2978
+ touch.isDoubleTap = true;
2979
+ touch.last = now;
2980
+ setTimeout(longTap, longTapDelay);
2981
+ if (!touch.el.data("ignore-pressed"))
2982
+ touch.el.addClass("selected");
2983
+ else
2984
+ touch.el.closest(".selectable").addClass("selected");
2985
+ }).bind('touchmove', function(e) {
2986
+ touch.x2 = e.touches[0].pageX;
2987
+ touch.y2 = e.touches[0].pageY;
2988
+ }).bind('touchend', function(e) {
2989
+ if (!touch.el) {
2990
+ touch = {};
2991
+ return;
2992
+ }
2993
+ if (!touch.el.data("ignore-pressed"))
2994
+ touch.el.removeClass("selected");
2995
+ else
2996
+ touch.el.closest(".selectable").removeClass("selected");
2997
+ if (touch.isDoubleTap) {
2998
+ touch.el.trigger('doubleTap');
2999
+ touch = {};
3000
+ } else if (Math.abs(touch.x1 - touch.x2) > 5 || Math.abs(touch.y1 - touch.y2) > 5) {
3001
+ (Math.abs(touch.x1 - touch.x2) > 30 || Math.abs(touch.y1 - touch.y2) > 30) &&
3002
+ touch.el.trigger('swipe') &&
3003
+ touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)));
3004
+ touch.x1 = touch.x2 = touch.y1 = touch.y2 = touch.last = 0;
3005
+ } else if ('last' in touch) {
3006
+ touch.el.trigger('tap');
3007
+ touchTimeout = setTimeout(function() {
3008
+ touchTimeout = null;
3009
+ if (touch.el)
3010
+ touch.el.trigger('singleTap');
3011
+ touch = {};
3012
+ }, 250);
3013
+ }
3014
+ }).bind('touchcancel', function() {
3015
+ touch = {}
3016
+ });
3017
+ });
3018
+
3019
+ ['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(m) {
3020
+ $.fn[m] = function(callback) {
3021
+ return this.bind(m, callback)
3022
+ }
3023
+ });
3024
+ })(jq);
3025
+ (function($ui){
3026
+
3027
+ function fadeTransition (oldDiv, currDiv, back) {
3028
+ oldDiv.style.display = "block";
3029
+ currDiv.style.display = "block";
3030
+ var that = $ui
3031
+ if (back) {
3032
+ that.css3animate(currDiv, {
3033
+ x: "0%",
3034
+ time: "1ms"
3035
+ });
3036
+ that.css3animate(oldDiv, {
3037
+ x: "0%",
3038
+ time: "200ms",
3039
+ opacity: .1,
3040
+ callback: function() {
3041
+ that.finishTransition(oldDiv);
3042
+ that.css3animate(oldDiv, {
3043
+ x: 0,
3044
+ time: "1ms",
3045
+ opacity: 1
3046
+ });
3047
+ currDiv.style.zIndex = 2;
3048
+ oldDiv.style.zIndex = 1;
3049
+ }
3050
+ });
3051
+ } else {
3052
+ oldDiv.style.zIndex = 1;
3053
+ currDiv.style.zIndex = 2;
3054
+ that.css3animate(oldDiv, {
3055
+ x: "0%",
3056
+ time: "200ms",
3057
+ callback: function() {
3058
+ that.css3animate(oldDiv, {
3059
+ x: 0,
3060
+ y: 0,
3061
+ time: "1ms",
3062
+ callback: function() {
3063
+ that.finishTransition(oldDiv);
3064
+ }
3065
+ });
3066
+ }
3067
+ });
3068
+ currDiv.style.opacity = 0;
3069
+ that.css3animate(currDiv, {
3070
+ x: "0%",
3071
+ time: "1ms",
3072
+ callback: function() {
3073
+ that.css3animate(currDiv, {
3074
+ x: "0%",
3075
+ time: "200ms",
3076
+ opacity: 1
3077
+ });
3078
+ }
3079
+ });
3080
+ }
3081
+ }
3082
+ $ui.availableTransitions.fade = fadeTransition;
3083
+ })($.ui);
3084
+ (function($ui){
3085
+
3086
+ function flipTransition (oldDiv, currDiv, back) {
3087
+ oldDiv.style.display = "block";
3088
+ currDiv.style.display = "block";
3089
+ var that = $ui
3090
+ if (back) {
3091
+ that.css3animate(currDiv, {
3092
+ x: "100%",
3093
+ time: "1ms",
3094
+ scale: .8,
3095
+ rotateY: "180deg",
3096
+ callback: function() {
3097
+ that.css3animate(currDiv, {
3098
+ x: "0%",
3099
+ time: "200ms"
3100
+ });
3101
+ }
3102
+ });
3103
+ that.css3animate(oldDiv, {
3104
+ x: "10%",
3105
+ time: "200ms",
3106
+ scale: .8,
3107
+ rotateY: "180deg",
3108
+ callback: function() {
3109
+ that.finishTransition(oldDiv);
3110
+ that.css3animate(oldDiv, {
3111
+ x: 0,
3112
+ time: "1ms",
3113
+ opacity: 1
3114
+ });
3115
+ currDiv.style.zIndex = 2;
3116
+ oldDiv.style.zIndex = 1;
3117
+ }
3118
+ });
3119
+ } else {
3120
+ oldDiv.style.zIndex = 1;
3121
+ currDiv.style.zIndex = 2;
3122
+ that.css3animate(oldDiv, {
3123
+ x: "100%",
3124
+ time: "200ms",
3125
+ scale: '.8',
3126
+ rotateY: "180deg",
3127
+ callback: function() {
3128
+ that.finishTransition(oldDiv);
3129
+ that.css3animate(oldDiv, {
3130
+ x: 0,
3131
+ y: 0,
3132
+ time: "1ms"
3133
+ });
3134
+ }
3135
+ });
3136
+ that.css3animate(currDiv, {
3137
+ x: "100%",
3138
+ time: "1ms",
3139
+ scale: .8,
3140
+ rotateY: "180deg",
3141
+ callback: function() {
3142
+ that.css3animate(currDiv, {
3143
+ x: "0%",
3144
+ time: "200ms"
3145
+ });
3146
+ }
3147
+ });
3148
+ }
3149
+ }
3150
+ $ui.availableTransitions.flip = flipTransition;
3151
+ })($.ui);
3152
+ (function($ui){
3153
+
3154
+ function popTransition(oldDiv, currDiv, back) {
3155
+ oldDiv.style.display = "block";
3156
+ currDiv.style.display = "block";
3157
+ var that = $ui
3158
+ if (back) {
3159
+ that.css3animate(currDiv, {
3160
+ x: "0%",
3161
+ time: "1ms"
3162
+ });
3163
+ that.css3animate(oldDiv, {
3164
+ x: "0%",
3165
+ time: "200ms",
3166
+ opacity: .1,
3167
+ scale: .2,
3168
+ origin: "50% 50%",
3169
+ callback: function() {
3170
+ that.finishTransition(oldDiv);
3171
+ that.css3animate(oldDiv, {
3172
+ x: 0,
3173
+ time: "1ms"
3174
+ });
3175
+ currDiv.style.zIndex = 2;
3176
+ oldDiv.style.zIndex = 1;
3177
+ }
3178
+ });
3179
+ } else {
3180
+ oldDiv.style.zIndex = 1;
3181
+ currDiv.style.zIndex = 2;
3182
+ that.css3animate(oldDiv, {
3183
+ x: "0%",
3184
+ time: "200ms",
3185
+ callback: function() {
3186
+ that.css3animate(oldDiv, {
3187
+ x: 0,
3188
+ y: 0,
3189
+ time: "1ms",
3190
+ callback: function() {
3191
+ that.finishTransition(oldDiv);
3192
+ }
3193
+ });
3194
+ }
3195
+ });
3196
+ that.css3animate(currDiv, {
3197
+ x: "0%",
3198
+ y: "0%",
3199
+ time: "1ms",
3200
+ scale: .2,
3201
+ origin: "50% 50%",
3202
+ opacity: .1,
3203
+ callback: function() {
3204
+ that.css3animate(currDiv, {
3205
+ x: "0%",
3206
+ time: "200ms",
3207
+ scale: 1,
3208
+ opacity: 1,
3209
+ origin: "0% 0%"
3210
+ });
3211
+ }
3212
+ });
3213
+ }
3214
+ }
3215
+ $ui.availableTransitions.pop = popTransition;
3216
+ })($.ui);
3217
+ (function($ui){
3218
+
3219
+ /**
3220
+ * Initiate a sliding transition. This is a sample to show how transitions are implemented. These are registered in $ui.availableTransitions and take in three parameters.
3221
+ * @param {Object} previous panel
3222
+ * @param {Object} current panel
3223
+ * @param {Boolean} go back
3224
+ * @title $ui.slideTransition(previousPanel,currentPanel,goBack);
3225
+ */
3226
+ function slideTransition(oldDiv, currDiv, back) {
3227
+ oldDiv.style.display = "block";
3228
+ currDiv.style.display = "block";
3229
+ var that = $ui
3230
+
3231
+ if (back) {
3232
+ that.css3animate(oldDiv, {
3233
+ x: "100%",
3234
+ time: "200ms",
3235
+ callback: function() {
3236
+ that.finishTransition(oldDiv);
3237
+ that.css3animate(oldDiv, {
3238
+ x: 0,
3239
+ time: "0ms"
3240
+ });
3241
+ }
3242
+ });
3243
+ that.css3animate(currDiv, {
3244
+ x: "-100%",
3245
+ time: "0ms",
3246
+ callback: function() {
3247
+ that.css3animate(currDiv, {
3248
+ x: "0%",
3249
+ time: "200ms"
3250
+ });
3251
+ }
3252
+ });
3253
+ } else {
3254
+ that.css3animate(oldDiv, {
3255
+ x: "-100%",
3256
+ time: "200ms",
3257
+ callback: function() {
3258
+ that.finishTransition(oldDiv);
3259
+ }
3260
+ });
3261
+ that.css3animate(currDiv, {
3262
+ x: "100%",
3263
+ time: "0ms",
3264
+ callback: function() {
3265
+ that.css3animate(currDiv, {
3266
+ x: "0%",
3267
+ time: "200ms"
3268
+ });
3269
+ }
3270
+ });
3271
+ }
3272
+ }
3273
+ $ui.availableTransitions.slide = slideTransition;
3274
+ $ui.availableTransitions['default'] = slideTransition;
3275
+ })($.ui);
3276
+ (function($ui){
3277
+
3278
+ function slideDownTransition (oldDiv, currDiv, back) {
3279
+ oldDiv.style.display = "block";
3280
+ currDiv.style.display = "block";
3281
+ var that = $ui;
3282
+ if (back) {
3283
+ that.css3animate(currDiv, {
3284
+ x: "0%",
3285
+ y: "0%",
3286
+ time: "1ms"
3287
+ });
3288
+ that.css3animate(oldDiv, {
3289
+ y: "-100%",
3290
+ x: "0%",
3291
+ time: "200ms",
3292
+ callback: function() {
3293
+ that.finishTransition(oldDiv);
3294
+ that.css3animate(oldDiv, {
3295
+ x: 0,
3296
+ y: 0,
3297
+ time: "1ms"
3298
+ });
3299
+ currDiv.style.zIndex = 2;
3300
+ oldDiv.style.zIndex = 1;
3301
+ }
3302
+ });
3303
+ } else {
3304
+ oldDiv.style.zIndex = 1;
3305
+ currDiv.style.zIndex = 2;
3306
+ that.css3animate(oldDiv, {
3307
+ x: "0%",
3308
+ time: "200ms",
3309
+ callback: function() {
3310
+ that.css3animate(oldDiv, {
3311
+ x: 0,
3312
+ y: 0,
3313
+ time: "1ms",
3314
+ callback: function() {
3315
+ that.finishTransition(oldDiv);
3316
+ }
3317
+ });
3318
+ }
3319
+ });
3320
+ that.css3animate(currDiv, {
3321
+ y: "-100%",
3322
+ x: "0%",
3323
+ time: "1ms",
3324
+ callback: function() {
3325
+ that.css3animate(currDiv, {
3326
+ y: "0%",
3327
+ x: "0%",
3328
+ time: "200ms"
3329
+ });
3330
+ }
3331
+ });
3332
+ }
3333
+ }
3334
+ $ui.availableTransitions.down = slideDownTransition;
3335
+ })($.ui);
3336
+ (function($ui){
3337
+
3338
+ function slideUpTransition(oldDiv, currDiv, back) {
3339
+ oldDiv.style.display = "block";
3340
+ currDiv.style.display = "block";
3341
+ var that = $ui;
3342
+ if (back) {
3343
+ that.css3animate(currDiv, {
3344
+ x: "00%",
3345
+ y: "0%",
3346
+ time: "1ms"
3347
+ });
3348
+ that.css3animate(oldDiv, {
3349
+ y: "100%",
3350
+ x: "00%",
3351
+ time: "200ms",
3352
+ callback: function() {
3353
+ that.finishTransition(oldDiv);
3354
+ that.css3animate(oldDiv, {
3355
+ x: 0,
3356
+ y: 0,
3357
+ time: "1ms"
3358
+ });
3359
+ currDiv.style.zIndex = 2;
3360
+ oldDiv.style.zIndex = 1;
3361
+ }
3362
+ });
3363
+ } else {
3364
+ oldDiv.style.zIndex = 1;
3365
+ currDiv.style.zIndex = 2;
3366
+ that.css3animate(oldDiv, {
3367
+ x: "00%",
3368
+ time: "200ms",
3369
+ callback: function() {
3370
+ that.css3animate(oldDiv, {
3371
+ x: 0,
3372
+ y: 0,
3373
+ time: "1ms",
3374
+ callback: function() {
3375
+ that.finishTransition(oldDiv);
3376
+ }
3377
+ });
3378
+ }
3379
+ });
3380
+ that.css3animate(currDiv, {
3381
+ y: "100%",
3382
+ x: "00%",
3383
+ time: "1ms",
3384
+ callback: function() {
3385
+ that.css3animate(currDiv, {
3386
+ y: "0%",
3387
+ x: "00%",
3388
+ time: "200ms"
3389
+ });
3390
+ }
3391
+ });
3392
+ }
3393
+ }
3394
+ $ui.availableTransitions.up = slideUpTransition;
3395
+ })($.ui);
3396
+