jqmobi-rails 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,99 @@
1
+ /**
2
+ * jq.web.actionsheet - a actionsheet for html5 mobile apps
3
+ * Copyright 2012 - AppMobi
4
+ */
5
+ (function($) {
6
+ $.fn["actionsheet"] = function(opts) {
7
+ var tmp;
8
+ for (var i = 0; i < this.length; i++) {
9
+ tmp = new actionsheet(this[i], opts);
10
+ }
11
+ return this.length == 1 ? tmp : this;
12
+ };
13
+ var actionsheet = (function() {
14
+ if (!window.WebKitCSSMatrix)
15
+ return;
16
+
17
+ var actionsheet = function(elID, opts) {
18
+ if (typeof elID == "string" || elID instanceof String) {
19
+ this.el = document.getElementById(elID);
20
+ } else {
21
+ this.el = elID;
22
+ }
23
+ if (!this.el) {
24
+ alert("Could not find element for actionsheet " + elID);
25
+ return;
26
+ }
27
+
28
+ if (this instanceof actionsheet) {
29
+ if(typeof(opts)=="object"){
30
+ for (j in opts) {
31
+ this[j] = opts[j];
32
+ }
33
+ }
34
+ } else {
35
+ return new actionsheet(elID, opts);
36
+ }
37
+
38
+ try {
39
+ var that = this;
40
+ var markStart = '</div><div id="jq_actionsheet"><div style="width:100%">';
41
+ var markEnd = '</div></div>';
42
+ var markup;
43
+ if (typeof opts == "string") {
44
+ markup = $(markStart + opts +"<a href='javascript:;' class='cancel'>Cancel</a>"+markEnd);
45
+ } else if (typeof opts == "object") {
46
+ markup = $(markStart + markEnd);
47
+ var container = $(markup.children().get());
48
+ opts.push({text:"Cancel",cssClasses:"cancel"});
49
+ for (var i = 0; i < opts.length; i++) {
50
+ var item = $('<a href="javascript:;" >' + (opts[i].text || "TEXT NOT ENTERED") + '</a>');
51
+ item[0].onclick = (opts[i].handler || function() {});
52
+ if (opts[i].cssClasses && opts[i].cssClasses.length > 0)
53
+ item.addClass(opts[i].cssClasses);
54
+ container.append(item);
55
+ }
56
+ }
57
+ $(elID).find("#jq_actionsheet").remove();
58
+ $(elID).find("#jq_action_mask").remove();
59
+ actionsheetEl = $(elID).append(markup);
60
+
61
+ markup.get().style.webkitTransition="all 0ms";
62
+ markup.css("-webkit-transform", "translate3d(0,"+(window.innerHeight*2) + "px,0)");
63
+ this.el.style.overflow = "hidden";
64
+ markup.on("click", "a",function(){that.hideSheet()});
65
+ this.activeSheet=markup;
66
+ $(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)"/>');
67
+ setTimeout(function(){
68
+ markup.get().style.webkitTransition="all 200ms";
69
+ var height=window.innerHeight-parseInt(markup.css("height"));
70
+ markup.css("-webkit-transform", "translate3d(0,"+(height)+"px,0)");
71
+ },10);
72
+ } catch (e) {
73
+ alert("error adding actionsheet" + e);
74
+ }
75
+ };
76
+ actionsheet.prototype = {
77
+ activeSheet:null,
78
+ hideSheet: function() {
79
+ var that=this;
80
+ this.activeSheet.off("click","a",function(){that.hideSheet()});
81
+ $(this.el).find("#jq_action_mask").remove();
82
+ this.activeSheet.get().style.webkitTransition="all 0ms";
83
+ var markup = this.activeSheet;
84
+ var theEl = this.el;
85
+ setTimeout(function(){
86
+
87
+ markup.get().style.webkitTransition="all 500ms";
88
+ markup.css("-webkit-transform", "translate3d(0,"+(window.innerHeight*2) + "px,0)");
89
+ setTimeout(function(){
90
+ markup.remove();
91
+ markup=null;
92
+ theEl.style.overflow = "none";
93
+ },500);
94
+ },10);
95
+ }
96
+ };
97
+ return actionsheet;
98
+ })();
99
+ })(jq);
@@ -0,0 +1,136 @@
1
+ /**
2
+ * $.alphaTable - a list table for jqMobi apps
3
+ *
4
+ * @copyright AppMobi 2011 - AppMobi
5
+ *
6
+ */ (function ($) {
7
+ $.fn["alphatable"] = function (scroller, opts) {
8
+ var tmp;
9
+ for (var i = 0; i < this.length; i++) {
10
+ tmp = new alphaTable(this[i], scroller, opts);
11
+
12
+ }
13
+ return this.length == 1 ? tmp : this;
14
+ };
15
+
16
+ var alphaTable = (function () {
17
+ if (!window.WebKitCSSMatrix) return;
18
+ var translateOpen = 'm11' in new WebKitCSSMatrix() ? "3d(" : "(";
19
+ var translateClose = 'm11' in new WebKitCSSMatrix() ? ",0)" : ")";
20
+ var alphaTable = function (el, scroller, opts) {
21
+
22
+ if (typeof el == "string") el = document.getElementById(el);
23
+ this.container = el.parentNode;
24
+ if (!this.container) {
25
+ alert("Error finding container for alphaTable " + el);
26
+ return;
27
+ }
28
+ if (this instanceof alphaTable) {
29
+ for (j in opts) {
30
+ this[j] = opts[j];
31
+ }
32
+ } else {
33
+ return new alphaTable(el, scroller, opts);
34
+ }
35
+ if (!scroller || typeof (scroller) != "object") {
36
+ return alert("Error: Please include an jq.web.scroll object to use this");
37
+ }
38
+ this.scroller = scroller;
39
+
40
+ this.el = el;
41
+ this.setupIndex();
42
+ this.setupLetterBox();
43
+ };
44
+
45
+ alphaTable.prototype = {
46
+ listCssClass: "",
47
+ letterBox: null,
48
+ isMoving: false,
49
+ prefix: "",
50
+ scrollToLetter: function (letter) {
51
+ var el = document.getElementById(this.prefix + letter);
52
+ if (el) {
53
+ var yPos = -el.offsetTop;
54
+ this.scroller.scrollTo({
55
+ x: 0,
56
+ y: yPos
57
+ });
58
+ }
59
+ },
60
+ setupIndex: function () {
61
+ var arrAlphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
62
+ var that = this;
63
+ var containerDiv = document.createElement("div");
64
+ containerDiv.id = "indexDIV_" + this.el.id;
65
+ containerDiv.style.cssText = "position:absolute;top:0px;right:20px;width:20px;font-size:6pt;font-weight:bold;color:#000;opacity:.5;border-radius:5px;text-align:center;z-index:9999;border:1px solid black;background:#666;padding-top:5px;padding-bottom:5px;";
66
+ containerDiv.className = this.listCssClass;
67
+ containerDiv.addEventListener("touchend", function (event) {
68
+ that.isMoving = false;
69
+ that.clearLetterBox()
70
+ }, false);
71
+ //To allow updating as we "scroll" with our finger, we need to capture the position on the containerDiv element and calculate the Y coordinates.
72
+ //On mobile devices, you can not do an "onmouseover" over multiple items and trigger events.
73
+ containerDiv.addEventListener("touchstart", function (event) {
74
+ if(event.touches[0].target==this) return;
75
+ that.isMoving = true;
76
+
77
+ var letter = document.elementFromPoint(event.changedTouches[0].clientX, event.changedTouches[0].clientY);
78
+ if(!letter||!letter.getAttribute("alphatable-item")||letter.getAttribute("alphatable-item").length==0)
79
+ return;
80
+ that.showLetter(letter.innerHTML);
81
+ that.scrollToLetter(letter.innerHTML);
82
+ event.preventDefault();
83
+ }, false);
84
+ containerDiv.addEventListener("touchmove", function (event) {
85
+ var letter = document.elementFromPoint(event.changedTouches[0].clientX, event.changedTouches[0].clientY);
86
+ if(!letter||!letter.getAttribute("alphatable-item")||letter.getAttribute("alphatable-item").length==0)
87
+ return;
88
+ if (!that.isMoving) return;
89
+ that.showLetter(letter.innerHTML);
90
+ that.scrollToLetter(letter.innerHTML);
91
+ event.preventDefault();
92
+ }, false);
93
+
94
+ //Create the alphabet
95
+ for (i = 0; i < arrAlphabet.length; i++) {
96
+ var tmpDiv = document.createElement("div");
97
+ tmpDiv.innerHTML = arrAlphabet[i];
98
+ tmpDiv.setAttribute("alphatable-item","true");
99
+ containerDiv.appendChild(tmpDiv);
100
+ }
101
+ this.container.appendChild(containerDiv);
102
+
103
+ var clientHeight = numOnly(containerDiv.clientHeight) - numOnly(containerDiv.style.top) - numOnly(containerDiv.style.paddingTop);
104
+ this.scroller.scrollTo({
105
+ x: 0,
106
+ y: 0
107
+ }); //There's a bug with webkit and css3. The letterbox would not show until -webkit-transform as applied.
108
+ containerDiv = null;
109
+
110
+ },
111
+ showLetter: function (letter) {
112
+ var that = this;
113
+ this.letterBox.style.display = "block";
114
+ if (this.letterBox.innerHTML != letter) {
115
+ that.letterBox.innerHTML = letter
116
+ }
117
+
118
+ },
119
+ clearLetterBox: function () {
120
+ this.letterBox.style.display = "none";
121
+ this.letterBox.innerHTML = "";
122
+ },
123
+ setupLetterBox: function () {
124
+ var div = document.createElement("div");
125
+ div.style.cssText = "-webkit-transform:translate3d(0,0,0);display:none;position:absolute;top:35%;left:35%;height:2em;width:15%;line-height:2em;text-align:center;font-size:2em;color:blue;background:#666;z-index:999999;border:1px solid black;border-raidus:10px;";
126
+ div.className = this.letterBoxCssClass;
127
+ div.innerHTML = "";
128
+ this.letterBox = div;
129
+ this.container.appendChild(div);
130
+ div = null;
131
+
132
+ }
133
+ };
134
+ return alphaTable;
135
+ })();
136
+ })(jq);
@@ -0,0 +1,415 @@
1
+ /**
2
+ * jq.web.carousel - a carousel library for html5 mobile apps
3
+ * @copyright AppMobi 2011 - AppMobi
4
+ *
5
+ */
6
+ (function($) {
7
+ var cache = [];
8
+ $.fn.carousel = function(opts) {
9
+ if (opts === undefined && this.length > 0)
10
+ {
11
+ return cache[this[0].id] ? cache[this[0].id] : null;
12
+ }
13
+ var tmp;
14
+ for (var i = 0; i < this.length; i++) {
15
+ tmp = new carousel(this[i], opts);
16
+ if (this[i].id)
17
+ cache[this[i].id] = tmp;
18
+ }
19
+ return this.length === 1 ? tmp : this;
20
+ };
21
+
22
+ var carousel = (function() {
23
+ if (!window.WebKitCSSMatrix) {
24
+ return;
25
+ }
26
+ var translateOpen = 'm11' in new WebKitCSSMatrix() ? "3d(" : "(";
27
+ var translateClose = 'm11' in new WebKitCSSMatrix() ? ",0)" : ")";
28
+
29
+ var carousel = function(containerEl, opts) {
30
+ if (typeof containerEl === "string" || containerEl instanceof String) {
31
+ this.container = document.getElementById(containerEl);
32
+ } else {
33
+ this.container = containerEl;
34
+ }
35
+ if (!this.container) {
36
+ alert("Error finding container for carousel " + containerEl);
37
+ return;
38
+ }
39
+ if (this instanceof carousel) {
40
+ for (var j in opts) {
41
+ if (opts.hasOwnProperty(j)) {
42
+ this[j] = opts[j];
43
+ }
44
+ }
45
+ } else {
46
+
47
+ return new carousel(containerEl, opts);
48
+ }
49
+ try {
50
+ var that = this;
51
+ this.pagingDiv = this.pagingDiv ? document.getElementById(this.pagingDiv) : null;
52
+
53
+
54
+ // initial setup
55
+ this.container.style.overflow = "hidden";
56
+ this.container.style['-webkit-box-orient'] = "vertical";
57
+ this.container.style['display'] = "-webkit-box";
58
+ this.container.style['-webkit-box-orient'] = "vertical";
59
+ if (this.vertical) {
60
+ this.horizontal = false;
61
+ }
62
+ var tmpHTML = this.container.innerHTML;
63
+ this.container.innerHTML = "";
64
+ var el = document.createElement("div");
65
+ el.innerHTML = tmpHTML;
66
+ if (this.horizontal) {
67
+ el.style.display = "-webkit-box";
68
+ el.style['-webkit-box-flex'] = 1;
69
+ }
70
+ else {
71
+ el.style.display = "block";
72
+ }
73
+ this.container.appendChild(el);
74
+ this.el = el;
75
+ this.refreshItems();
76
+ el.addEventListener('touchmove', function(e) {
77
+ that.touchMove(e);
78
+ }, false);
79
+ el.addEventListener('touchend', function(e) {
80
+ that.touchEnd(e);
81
+ }, false);
82
+ el.addEventListener('touchstart', function(e) {
83
+ that.touchStart(e);
84
+ }, false);
85
+ var that = this;
86
+ window.addEventListener("orientationchange", function() {
87
+ that.onMoveIndex(that.carouselIndex,0);
88
+ }, false);
89
+
90
+ } catch (e) {
91
+ console.log("error adding carousel " + e);
92
+ }
93
+ };
94
+
95
+ carousel.prototype = {
96
+ startX: 0,
97
+ startY: 0,
98
+ dx: 0,
99
+ dy: 0,
100
+ myDivWidth: 0,
101
+ myDivHeight: 0,
102
+ cssMoveStart: 0,
103
+ childrenCount: 0,
104
+ carouselIndex: 0,
105
+ vertical: false,
106
+ horizontal: true,
107
+ el: null,
108
+ movingElement: false,
109
+ container: null,
110
+ pagingDiv: null,
111
+ pagingCssName: "carousel_paging",
112
+ pagingCssNameSelected: "carousel_paging_selected",
113
+ pagingFunction: null,
114
+ lockMove:false,
115
+ // handle the moving function
116
+ touchStart: function(e) {
117
+ this.myDivWidth = numOnly(this.container.clientWidth);
118
+ this.myDivHeight = numOnly(this.container.clientHeight);
119
+ this.lockMove=false;
120
+ if (event.touches[0].target && event.touches[0].target.type !== undefined) {
121
+ var tagname = event.touches[0].target.tagName.toLowerCase();
122
+ if (tagname === "select" || tagname === "input" || tagname === "button") // stuff we need to allow
123
+ {
124
+ return;
125
+ }
126
+ }
127
+ if (e.touches.length === 1) {
128
+
129
+ this.movingElement = true;
130
+ this.startY = e.touches[0].pageY;
131
+ this.startX = e.touches[0].pageX;
132
+ //e.preventDefault();
133
+ //e.stopPropagation();
134
+ if (this.vertical) {
135
+ try {
136
+ this.cssMoveStart = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el, null).webkitTransform).f);
137
+ } catch (ex1) {
138
+ this.cssMoveStart = 0;
139
+ }
140
+ } else {
141
+ try {
142
+ this.cssMoveStart = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el, null).webkitTransform).e);
143
+ } catch (ex1) {
144
+ this.cssMoveStart = 0;
145
+ }
146
+ }
147
+ }
148
+ },
149
+ touchMove: function(e) {
150
+ // e.preventDefault();
151
+ // e.stopPropagation();
152
+ if(!this.movingElement)
153
+ return;
154
+ if (e.touches.length > 1) {
155
+ return this.touchEnd(e);
156
+ }
157
+
158
+ var rawDelta = {
159
+ x: e.touches[0].pageX - this.startX,
160
+ y: e.touches[0].pageY - this.startY
161
+ };
162
+
163
+ if (this.vertical) {
164
+ var movePos = { x: 0, y: 0 };
165
+ this.dy = e.touches[0].pageY - this.startY;
166
+ this.dy += this.cssMoveStart;
167
+ movePos.y = this.dy;
168
+ e.preventDefault();
169
+ e.stopPropagation();
170
+ } else {
171
+ if (!this.lockMove&&isHorizontalSwipe(rawDelta.x, rawDelta.y)) {
172
+
173
+ var movePos = {x: 0,y: 0};
174
+ this.dx = e.touches[0].pageX - this.startX;
175
+ this.dx += this.cssMoveStart;
176
+ e.preventDefault();
177
+ e.stopPropagation();
178
+ movePos.x = this.dx;
179
+ }
180
+ else
181
+ return this.lockMove=true;
182
+ }
183
+
184
+ var totalMoved = this.vertical ? ((this.dy % this.myDivHeight) / this.myDivHeight * 100) * -1 : ((this.dx % this.myDivWidth) / this.myDivWidth * 100) * -1; // get a percentage of movement.
185
+ if(movePos)
186
+ this.moveCSS3(this.el, movePos);
187
+ },
188
+ touchEnd: function(e) {
189
+ if (!this.movingElement) {
190
+ return;
191
+ }
192
+ // e.preventDefault();
193
+ // e.stopPropagation();
194
+ var runFinal = false;
195
+ try {
196
+ var endPos = this.vertical ? numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el, null).webkitTransform).f) : numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el, null).webkitTransform).e);
197
+ if (endPos > 0) {
198
+ this.moveCSS3(this.el, {
199
+ x: 0,
200
+ y: 0
201
+ }, "300");
202
+ } else {
203
+ var totalMoved = this.vertical ? ((this.dy % this.myDivHeight) / this.myDivHeight * 100) * -1 : ((this.dx % this.myDivWidth) / this.myDivWidth * 100) * -1; // get a percentage of movement.
204
+ // Only need
205
+ // to drag 3% to trigger an event
206
+ var currInd = this.carouselIndex;
207
+ if (endPos < this.cssMoveStart && totalMoved > 3) {
208
+ currInd++; // move right/down
209
+ } else if ((endPos > this.cssMoveStart && totalMoved < 97)) {
210
+ currInd--; // move left/up
211
+ }
212
+ if (currInd > (this.childrenCount - 1)) {
213
+ currInd = this.childrenCount - 1;
214
+ }
215
+ if (currInd < 0) {
216
+ currInd = 0;
217
+ }
218
+ var movePos = {
219
+ x: 0,
220
+ y: 0
221
+ };
222
+ if (this.vertical) {
223
+ movePos.y = (currInd * this.myDivHeight * -1);
224
+ }
225
+ else {
226
+ movePos.x = (currInd * this.myDivWidth * -1);
227
+ }
228
+
229
+ this.moveCSS3(this.el, movePos, "150");
230
+
231
+ if (this.pagingDiv && this.carouselIndex !== currInd) {
232
+ document.getElementById(this.container.id + "_" + this.carouselIndex).className = this.pagingCssName;
233
+ document.getElementById(this.container.id + "_" + currInd).className = this.pagingCssNameSelected;
234
+ }
235
+ if (this.carouselIndex != currInd)
236
+ runFinal = true;
237
+ this.carouselIndex = currInd;
238
+ }
239
+ } catch (e) {
240
+ console.log(e);
241
+ }
242
+ this.dx = 0;
243
+ this.movingElement = false;
244
+ this.startX = 0;
245
+ this.dy = 0;
246
+ this.startY = 0;
247
+ if (runFinal && this.pagingFunction && typeof this.pagingFunction == "function")
248
+ this.pagingFunction(this.carouselIndex);
249
+ },
250
+ onMoveIndex: function(newInd,transitionTime) {
251
+
252
+ this.myDivWidth = numOnly(this.container.clientWidth);
253
+ this.myDivHeight = numOnly(this.container.clientHeight);
254
+ var runFinal = false;
255
+ try {
256
+
257
+ document.getElementById(this.container.id + "_" + this.carouselIndex).className = this.pagingCssName;
258
+ var newTime = Math.abs(newInd - this.carouselIndex);
259
+
260
+ var ind = newInd;
261
+ if (ind < 0)
262
+ ind = 0;
263
+ if (ind > this.childrenCount - 1) {
264
+ ind = this.childrenCount - 1;
265
+ }
266
+ var movePos = {
267
+ x: 0,
268
+ y: 0
269
+ };
270
+ if (this.vertical) {
271
+ movePos.y = (ind * this.myDivHeight * -1);
272
+ }
273
+ else {
274
+ movePos.x = (ind * this.myDivWidth * -1);
275
+ }
276
+
277
+ var time =transitionTime?transitionTime: 50 + parseInt((newTime * 20));
278
+ this.moveCSS3(this.el, movePos, time);
279
+ if (this.carouselIndex != ind)
280
+ runFinal = true;
281
+ this.carouselIndex = ind;
282
+ if (this.pagingDiv) {
283
+
284
+ document.getElementById(this.container.id + "_" + this.carouselIndex).className = this.pagingCssNameSelected;
285
+ }
286
+ } catch (e) {
287
+ console.log("Error " + e);
288
+ }
289
+ if (runFinal && this.pagingFunction && typeof this.pagingFunction == "function")
290
+ this.pagingFunction(currInd);
291
+ },
292
+
293
+ moveCSS3: function(el, distanceToMove, time, timingFunction) {
294
+ if (!time)
295
+ time = 0;
296
+ else
297
+ time = parseInt(time);
298
+ if (!timingFunction)
299
+ timingFunction = "linear";
300
+
301
+ el.style.webkitTransform = "translate" + translateOpen + distanceToMove.x + "px," + distanceToMove.y + "px" + translateClose;
302
+ el.style.webkitTransitionDuration = time + "ms";
303
+ el.style.webkitBackfaceVisiblity = "hidden";
304
+ el.style.webkitTransformStyle = "preserve-3d";
305
+ el.style.webkitTransitionTimingFunction = timingFunction;
306
+ },
307
+
308
+ addItem: function(el) {
309
+ if (el && el.nodeType) {
310
+
311
+ this.container.childNodes[0].appendChild(el);
312
+ this.refreshItems();
313
+ }
314
+ },
315
+ refreshItems: function() {
316
+ var childrenCounter = 0;
317
+ var that = this;
318
+ var el = this.el;
319
+ n = el.childNodes[0];
320
+ var widthParam;
321
+ var heightParam = "100%";
322
+ var elems = [];
323
+ for (; n; n = n.nextSibling) {
324
+ if (n.nodeType === 1) {
325
+ elems.push(n);
326
+ childrenCounter++;
327
+ }
328
+ }
329
+ var param = (100 / childrenCounter) + "%";
330
+ this.childrenCount = childrenCounter;
331
+ widthParam = parseFloat(100 / this.childrenCount) + "%";
332
+ for (var i = 0; i < elems.length; i++) {
333
+ if (this.horizontal) {
334
+ elems[i].style.width = widthParam;
335
+ elems[i].style.height = "100%";
336
+ }
337
+ else {
338
+ elems[i].style.height = widthParam;
339
+ elems[i].style.width = "100%";
340
+ elems[i].style.display = "block";
341
+ }
342
+ }
343
+ this.moveCSS3(el, {
344
+ x: 0,
345
+ y: 0
346
+ });
347
+ if (this.horizontal) {
348
+ el.style.width = Math.ceil((this.childrenCount) * 100) + "%";
349
+ el.style.height = "100%";
350
+ el.style['min-height'] = "100%"
351
+ }
352
+ else {
353
+ el.style.width = "100%";
354
+ el.style.height = Math.ceil((this.childrenCount) * 100) + "%";
355
+ el.style['min-height'] = Math.ceil((this.childrenCount) * 100) + "%";
356
+ }
357
+ // Create the paging dots
358
+ if (this.pagingDiv) {
359
+ this.pagingDiv.innerHTML = ""
360
+ for (i = 0; i < this.childrenCount; i++) {
361
+
362
+ var pagingEl = document.createElement("div");
363
+ pagingEl.id = this.container.id + "_" + i;
364
+ pagingEl.pageId = i;
365
+ if (i !== 0) {
366
+ pagingEl.className = this.pagingCssName;
367
+ }
368
+ else {
369
+ pagingEl.className = this.pagingCssNameSelected;
370
+ }
371
+ pagingEl.onclick = function() {
372
+ that.onMoveIndex(this.pageId);
373
+ };
374
+ var spacerEl = document.createElement("div");
375
+
376
+ spacerEl.style.width = "20px";
377
+ if(this.horizontal){
378
+ spacerEl.style.cssFloat = "left";
379
+ spacerEl.innerHTML = "&nbsp;";
380
+ }
381
+ else{
382
+ spacerEl.innerHTML="&nbsp;";
383
+ spacerEl.style.display="block";
384
+ }
385
+
386
+ this.pagingDiv.appendChild(pagingEl);
387
+ if (i + 1 < (this.childrenCount))
388
+ this.pagingDiv.appendChild(spacerEl);
389
+ pagingEl = null;
390
+ spacerEl = null;
391
+ }
392
+ this.pagingDiv.style.width = (this.childrenCount) * 50 + "px";
393
+ this.pagingDiv.style.height = "25px";
394
+ }
395
+ this.onMoveIndex(this.carouselIndex);
396
+
397
+ }
398
+
399
+ };
400
+ return carousel;
401
+ })();
402
+
403
+ function isHorizontalSwipe(xAxis, yAxis) {
404
+ var X = xAxis;
405
+ var Y = yAxis;
406
+ var Z = Math.round(Math.sqrt(Math.pow(X,2)+Math.pow(Y,2))); //the distance - rounded - in pixels
407
+ var r = Math.atan2(Y,X); //angle in radians
408
+ var swipeAngle = Math.round(r*180/Math.PI); //angle in degrees
409
+ if ( swipeAngle < 0 ) { swipeAngle = 360 - Math.abs(swipeAngle); } // for negative degree values
410
+ if (((swipeAngle <= 215) && (swipeAngle >= 155)) || ((swipeAngle <= 45) && (swipeAngle >= 0)) || ((swipeAngle <= 360) && (swipeAngle >= 315))) // horizontal angles with threshold
411
+ {return true; }
412
+ else {return false}
413
+ }
414
+
415
+ })(jq);