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,155 @@
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);
@@ -0,0 +1,224 @@
1
+ /**
2
+ * jq.web.drawer - a drawer for html5 mobile apps
3
+ * Copyright 2011 - AppMobi
4
+ */ (function ($) {
5
+ $.fn["drawer"] = function (opts) {
6
+ var tmp;
7
+ for (var i = 0; i < this.length; i++) {
8
+ tmp = new drawer(this[i], opts);
9
+ }
10
+ return this.length == 1 ? tmp : this;
11
+ };
12
+ var drawer = (function () {
13
+ if (!window.WebKitCSSMatrix) return;
14
+ var translateOpen = 'm11' in new WebKitCSSMatrix() ? "3d(" : "(";
15
+ var translateClose = 'm11' in new WebKitCSSMatrix() ? ",0)" : ")";
16
+ var touchStarted = false;
17
+
18
+ var drawer = function (elID, opts) {
19
+ if (typeof elID == "string" || elID instanceof String) {
20
+ this.el = document.getElementById(elID);
21
+ } else {
22
+ this.el = elID;
23
+ }
24
+ if (!this.el) {
25
+ alert("Could not find element for drawer " + elID);
26
+ return;
27
+ }
28
+
29
+ if (this instanceof drawer) {
30
+ for (j in opts) {
31
+ this[j] = opts[j];
32
+ }
33
+ } else {
34
+ return new drawer(elID, opts);
35
+ }
36
+ this.direction=this.direction.toLowerCase();
37
+ try {
38
+ this.handle = this.el.querySelectorAll(".drawer_handle")[0];
39
+ if (!this.handle) return alert("Could not find handle for drawer - " + elID);
40
+ var that = this;
41
+ this.handle.addEventListener('touchmove', function (e) {
42
+ that.touchMove(e);
43
+ }, false);
44
+ this.handle.addEventListener('touchend', function (e) {
45
+ that.touchEnd(e);
46
+ }, false);
47
+
48
+ } catch (e) {
49
+ alert("error adding drawer" + e);
50
+ }
51
+ this.zIndex=$(this.el).css("zIndex");
52
+ };
53
+
54
+ drawer.prototype = {
55
+ lockY: 0,
56
+ lockX:0,
57
+ boolScrollLock: false,
58
+ currentDrawer: null,
59
+ maxTop: 0,
60
+ startTop: 0,
61
+ maxLeft:0,
62
+ startLeft:0,
63
+ timeMoved: 0,
64
+ vdistanceMoved: 0,
65
+ hdistanceMoved:0,
66
+ direction: "down",
67
+ prevTime: 0,
68
+ handle: null,
69
+ zIndex:1,
70
+ // horizontal scrolling
71
+ // handle the moving function
72
+ touchMove: function (event) {
73
+ try {
74
+ if (!touchStarted) {
75
+ touchStarted = true;
76
+ this.touchStart(event);
77
+ }
78
+ if (this.currentDrawer != null) {
79
+ event.preventDefault();
80
+ var drawerPoints = {
81
+ x: 0,
82
+ y: 0
83
+ };
84
+ if(this.direction=="down"||this.direction=="up"){
85
+ var newTop = 0,
86
+ prevTop = 0;
87
+ var deltaY = this.lockY - event.touches[0].pageY;
88
+ deltaY = -deltaY;
89
+ var newTop = this.startTop + deltaY;
90
+ var top = -newTop;
91
+ try {
92
+ var prevTop = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).f);
93
+ } catch (prevTopE) {
94
+ var prevTop = 0;
95
+ }
96
+ drawerPoints.y = newTop;
97
+ this.vdistanceMoved += Math.abs(prevTop) - Math.abs(newTop);
98
+ }
99
+ else {
100
+ var newLeft = 0,
101
+ prevLeft = 0;
102
+ var deltaX = this.lockX - event.touches[0].pageX;
103
+ deltaX = -deltaX;
104
+ var newLeft = this.startLeft + deltaX;
105
+ var left = -newLeft;
106
+ try {
107
+ var prevLeft = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).e);
108
+ } catch (prevTopE) {
109
+ var prevLeft = 0;
110
+ }
111
+ drawerPoints.x = newLeft;
112
+ this.hdistanceMoved += Math.abs(prevLeft) - Math.abs(newLeft);
113
+ }
114
+ this.drawerMove(this.currentDrawer, drawerPoints, 0);
115
+ }
116
+ } catch (e) {
117
+ alert("error in scrollMove: " + e);
118
+ }
119
+ },
120
+
121
+ touchStart: function (event) {
122
+
123
+ var handle = this.handle;
124
+ var eleScrolling = this.el;
125
+ if (!handle) return;
126
+
127
+ try {
128
+ // Allow interaction to legit calls, like select boxes, etc.
129
+ if (event.touches[0].target && event.touches[0].target.type != undefined) {
130
+ var tagname = event.touches[0].target.tagName.toLowerCase();
131
+ if (tagname == "select" || tagname == "input" || tagname == "button") // stuff we need to allow
132
+ // access to
133
+ return;
134
+ }
135
+ this.vdistanceMoved = 0;
136
+ this.hdistanceMoved = 0;
137
+
138
+ this.maxTop = numOnly(this.el.style.height) - numOnly(this.handle.style.height);
139
+ this.maxLeft = numOnly(this.el.style.width) - numOnly(this.handle.style.width);
140
+
141
+ if (this.direction == "up") this.maxTop *= -1;
142
+ if (this.direction=="left") this.maxLeft*=-1;
143
+ if (event.touches.length == 1 && this.boolScrollLock == false) {
144
+ try {
145
+ this.startTop = numOnly(new WebKitCSSMatrix(window.getComputedStyle(eleScrolling).webkitTransform).f);
146
+ this.startLeft = numOnly(new WebKitCSSMatrix(window.getComputedStyle(eleScrolling).webkitTransform).e);
147
+ } catch (e) {
148
+ this.startTop = 0;
149
+ this.startLeft=0;
150
+ console.log("error drawer touchstart " + e);
151
+ }
152
+ this.lockY = event.touches[0].pageY;
153
+ this.lockX=event.touches[0].pageX;
154
+ this.currentDrawer = eleScrolling;
155
+ event.preventDefault();
156
+ }
157
+ } catch (e) {
158
+ alert("error in drawer start: " + e);
159
+ }
160
+ },
161
+
162
+ // touchend callback. Set the current scrolling object and scrollbar to
163
+ // null
164
+ touchEnd: function (event) {
165
+ if (this.currentDrawer != null) {
166
+ event.preventDefault();
167
+ event.stopPropagation();
168
+
169
+ var drawerPoints = {
170
+ x: 0,
171
+ y: 0
172
+ };
173
+ if(this.direction=="up"||this.direction=="down"){
174
+ var myDistance = -this.vdistanceMoved;
175
+ var percentMoved = Math.ceil(Math.abs(myDistance) / Math.abs(this.maxTop) * 100);
176
+ var prevTop = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).f);
177
+ if (percentMoved > 17) {
178
+
179
+ if (myDistance > 0) drawerPoints.y = this.maxTop;
180
+ else drawerPoints.y = 0;
181
+ } else {
182
+ if (Math.floor(this.maxTop / prevTop) > 2) drawerPoints.y = 0;
183
+ else drawerPoints.y = this.maxTop;
184
+ }
185
+
186
+ }
187
+ else {
188
+ var myDistance = -this.hdistanceMoved;
189
+ var percentMoved = Math.ceil(Math.abs(myDistance) / Math.abs(this.maxLeft) * 100);
190
+ var prevLeft = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).e);
191
+ if (percentMoved > 17) {
192
+
193
+ if (myDistance > 0) drawerPoints.x = this.maxLeft;
194
+ else drawerPoints.x = 0;
195
+ } else {
196
+ if (Math.floor(this.maxLeft / prevLeft) > 2) drawerPoints.y = 0;
197
+ else drawerPoints.x = this.maxLeft;
198
+ }
199
+ }
200
+ if(drawerPoints.y>0||drawerPoints.x>0)
201
+ this.el.zIndex="9999";
202
+ else
203
+ this.el.zIndex=this.zIndex;
204
+
205
+ this.drawerMove(this.currentDrawer, drawerPoints, 300, "ease-out");
206
+ this.currentDrawer = null;
207
+ }
208
+ this.vdistanceMoved = 0;
209
+ touchStarted = false;
210
+ },
211
+
212
+ drawerMove: function (el, distanceToMove, time, timingFunction) {
213
+ if (!time) time = 0;
214
+ if (!timingFunction) timingFunction = "linear";
215
+
216
+ el.style.webkitTransform = "translate" + translateOpen + distanceToMove.x+"px," + distanceToMove.y + "px" + translateClose;
217
+ el.style.webkitTransitionDuration = time + "ms";
218
+ el.style.webkitBackfaceVisiblity = "hidden";
219
+ el.style.webkitTransitionTimingFunction = timingFunction;
220
+ }
221
+ };
222
+ return drawer;
223
+ })();
224
+ })(jq);
@@ -0,0 +1,110 @@
1
+ /**
2
+ * jq.fx.js
3
+ * FX library for jqMobi
4
+ *
5
+ */
6
+ (function ($) {
7
+ var noop = function () {};
8
+ /**
9
+ * Fade out an element by setting the opacity to 0 and hiding it when it's finished
10
+ ```
11
+ $('.tool_tip').fadeOut('300ms');
12
+ ```
13
+ *
14
+ * @param {String} animation time
15
+ * @param {Function} [callback]
16
+ * @title $().fadeOut(time,callback);
17
+ */
18
+ $.fn.fadeOut = function (time, cb, opc) {
19
+ if (this.length == 0) return;
20
+ if (!time) time = 0;
21
+ var that = this;
22
+ var callbackFn = noop;
23
+ if (!cb) cb = noop;
24
+ if (!opc) {
25
+ opc = 0;
26
+ callbackFn = function () {
27
+ this.hide();
28
+ }
29
+ }
30
+ var opts = {
31
+ opacity: opc,
32
+ time: time,
33
+ callback: function () {
34
+ cb.apply(that);
35
+ callbackFn.apply(that);
36
+ }
37
+ }
38
+ this.css3Animate(opts);
39
+ return this;
40
+ };
41
+ /**
42
+ * Fade in an element by setting the opacity to 1. We will set the display property so it's shown
43
+ ```
44
+ $('.tool_tip').fadeIn('300ms');
45
+ ```
46
+ *
47
+ * @param {String} animation time
48
+ * @param {Function} [callback]
49
+ * @title $().fadeIn(time,callback);
50
+ */
51
+ $.fn.fadeIn = function (time, callback) {
52
+
53
+ if (!time) time = "300ms";
54
+ this.show();
55
+ this.css("opacity", '.1');
56
+ var that = this;
57
+ window.setTimeout(function () {
58
+ that.fadeOut(time, callback, 10);
59
+ }, 1);
60
+ return this;
61
+ };
62
+ /**
63
+ * Toggle slide in/out a element based off time. We handle hiding/showing and keeping the previous height
64
+ ```
65
+ $('.tool_tip').slideToggle('300ms');
66
+ ```
67
+ *
68
+ * @param {String} animation time
69
+ * @param {Function} [callback]
70
+ * @param {String} css3 easing method
71
+ * @title $().slideToggle(time,callback,easing);
72
+ */
73
+ $.fn.slideToggle = function (duration, callback, easing) {
74
+ var opts = {
75
+ time: duration ? duration : "500ms",
76
+ callback: callback ? callback : null,
77
+ easing: easing ? easing : "linear"
78
+ }
79
+ for (var i = 0; i < this.length; i++) {
80
+ var hideshow = this.css("display", null, this[i]);
81
+ var expand = false;
82
+ var elem = $(this[i]);
83
+ if (hideshow == "none") {
84
+ elem.show();
85
+ expand = true;
86
+ }
87
+ var height = this.css("height", null, this[i]);
88
+ if (expand) {
89
+ elem.css("height", "0px");
90
+ opts['height'] = height;
91
+ } else {
92
+ opts['height'] = "0px";
93
+ var oldCB = callback;
94
+ callback = function () {
95
+ elem.hide();
96
+ var cbOpts = {
97
+ height: height,
98
+ time: "0ms"
99
+ }
100
+ elem.css3Animate(cbOpts);
101
+ }
102
+ }
103
+ if (callback) opts['callback'] = callback;
104
+ window.setTimeout(function () {
105
+ elem.css3Animate(opts);
106
+ }, 1);
107
+ }
108
+ return this;
109
+ }
110
+ })(jq);
@@ -0,0 +1,45 @@
1
+ /*
2
+ * jq.web.passwordBox - password box replacement for html5 mobile apps on android due to a bug with CSS3 translate3d
3
+ * @copyright 2011 - AppMobi
4
+ */
5
+ (function ($) {
6
+ $["passwordBox"] = function () {
7
+
8
+ return new passwordBox();
9
+ };
10
+
11
+ var passwordBox = function () {
12
+ this.oldPasswords = {};
13
+ };
14
+ passwordBox.prototype = {
15
+ showPasswordPlainText: false,
16
+ getOldPasswords: function (elID) {
17
+ // if ($.os.android == false) return; - iOS users seem to want this too, so we'll let everyone join the party
18
+ var container = elID && document.getElementById(elID) ? document.getElementById(elID) : document;
19
+ if (!container) {
20
+ alert("Could not find container element for passwordBox " + elID);
21
+ return;
22
+ }
23
+ var sels = container.getElementsByTagName("input");
24
+
25
+ var that = this;
26
+ for (var i = 0; i < sels.length; i++) {
27
+ if (sels[i].type != "password") continue;
28
+
29
+ sels[i].type = "text";
30
+ sels[i].style['-webkit-text-security'] = "disc";
31
+ }
32
+ },
33
+
34
+ changePasswordVisiblity: function (what, id) {
35
+ what = parseInt(what);
36
+ var theEl = document.getElementById(id);
37
+ if (what == 1) { //show
38
+ theEl.style['-webkit-text-security'] = "none";
39
+ } else {
40
+ theEl.style['-webkit-text-security'] = "disc";
41
+ }
42
+ theEl = null;
43
+ }
44
+ };
45
+ })(jq);