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,201 @@
1
+ /**
2
+ * jq.popup - a popup/alert library for html5 mobile apps
3
+ * @copyright Indiepath 2011 - Tim Fisher
4
+ * Modifications/enhancements by appMobi for jqMobi
5
+ *
6
+ */
7
+
8
+ /* EXAMPLE
9
+ $('body').popup({
10
+ title:"Alert! Alert!",
11
+ message:"This is a test of the emergency alert system!! Don't PANIC!",
12
+ cancelText:"Cancel me",
13
+ cancelCallback: function(){console.log("cancelled");},
14
+ doneText:"I'm done!",
15
+ doneCallback: function(){console.log("Done for!");},
16
+ cancelOnly:false,
17
+ doneClass:'button',
18
+ cancelClass:'button',
19
+ onShow:function(){console.log('showing popup');}
20
+ autoCloseDone:true, //default is true will close the popup when done is clicked.
21
+ suppressTitle:false //Do not show the title if set to true
22
+ });
23
+
24
+ You can programatically trigger a close by dispatching a "close" event to it.
25
+
26
+ $('body').popup({title:'Alert',id:'myTestPopup'});
27
+ $("#myTestPopup").trigger("close");
28
+
29
+ */
30
+ (function($) {
31
+
32
+ $.fn.popup = function(opts) {
33
+ return new popup(this[0], opts);
34
+ };
35
+ var queue = [];
36
+ var popup = (function() {
37
+ var popup = function(containerEl, opts) {
38
+
39
+ if (typeof containerEl === "string" || containerEl instanceof String) {
40
+ this.container = document.getElementById(containerEl);
41
+ } else {
42
+ this.container = containerEl;
43
+ }
44
+ if (!this.container) {
45
+ alert("Error finding container for popup " + containerEl);
46
+ return;
47
+ }
48
+
49
+ try {
50
+ if (typeof (opts) === "string" || typeof (opts) === "number")
51
+ opts = {message: opts,cancelOnly: "true",cancelText: "OK"};
52
+ this.id = id = opts.id = opts.id || $.uuid(); //opts is passed by reference
53
+ var self = this;
54
+ this.title = opts.suppressTitle?"":(opts.title || "Alert");
55
+ this.message = opts.message || "";
56
+ this.cancelText = opts.cancelText || "Cancel";
57
+ this.cancelCallback = opts.cancelCallback || function() {
58
+ };
59
+ this.cancelClass = opts.cancelClass || "button";
60
+ this.doneText = opts.doneText || "Done";
61
+ this.doneCallback = opts.doneCallback || function(self) {
62
+ self.hide();
63
+ };
64
+ this.doneClass = opts.doneClass || "button";
65
+ this.cancelOnly = opts.cancelOnly || false;
66
+ this.onShow = opts.onShow || function(){};
67
+ this.autoCloseDone=opts.autoCloseDone!==undefined?opts.autoCloseDone:true;
68
+
69
+ queue.push(this);
70
+ if (queue.length == 1)
71
+ this.show();
72
+ } catch (e) {
73
+ console.log("error adding popup " + e);
74
+ }
75
+
76
+ };
77
+
78
+ popup.prototype = {
79
+ id: null,
80
+ title: null,
81
+ message: null,
82
+ cancelText: null,
83
+ cancelCallback: null,
84
+ cancelClass: null,
85
+ doneText: null,
86
+ doneCallback: null,
87
+ doneClass: null,
88
+ cancelOnly: false,
89
+ onShow: null,
90
+ autoCloseDone:true,
91
+ supressTitle:false,
92
+ show: function() {
93
+ var self = this;
94
+ var markup = '<div id="' + this.id + '" class="jqPopup hidden">\
95
+ <header>' + this.title + '</header>\
96
+ <div><div style="width:1px;height:1px;-webkit-transform:translate3d(0,0,0);float:right"></div>' + this.message + '</div>\
97
+ <footer style="clear:both;">\
98
+ <a href="javascript:;" class="'+this.cancelClass+'" id="cancel">' + this.cancelText + '</a>\
99
+ <a href="javascript:;" class="'+this.doneClass+'" id="action">' + this.doneText + '</a>\
100
+ </footer>\
101
+ </div></div>';
102
+ $(this.container).append($(markup));
103
+
104
+ $("#" + this.id).bind("close", function(){
105
+ self.hide();
106
+ })
107
+
108
+ if (this.cancelOnly) {
109
+ $("#" + this.id).find('A#action').hide();
110
+ $("#" + this.id).find('A#cancel').addClass('center');
111
+ }
112
+ $("#" + this.id).find('A').each(function() {
113
+ var button = $(this);
114
+ button.bind('click', function(e) {
115
+ if (button.attr('id') == 'cancel') {
116
+ self.cancelCallback.call(self.cancelCallback, self);
117
+ self.hide();
118
+ } else {
119
+ self.doneCallback.call(self.doneCallback, self);
120
+ if(self.autoCloseDone)
121
+ self.hide();
122
+ }
123
+ e.preventDefault();
124
+ });
125
+ });
126
+ self.positionPopup();
127
+ $.blockUI(0.5);
128
+ $('#' + self.id).removeClass('hidden');
129
+ $('#' + self.id).bind("orientationchange", function() {
130
+ self.positionPopup();
131
+ });
132
+
133
+ this.onShow(this);
134
+
135
+ },
136
+
137
+ hide: function() {
138
+ var self = this;
139
+ $('#' + self.id).addClass('hidden');
140
+ $.unblockUI();
141
+ setTimeout(function() {
142
+ self.remove();
143
+ }, 250);
144
+ },
145
+
146
+ remove: function() {
147
+ var self = this;
148
+ var $el=$("#"+self.id);
149
+ $el.find('BUTTON#action').unbind('click');
150
+ $el.find('BUTTON#cancel').unbind('click');
151
+ $el.unbind("orientationchange").remove();
152
+ queue.splice(0, 1);
153
+ if (queue.length > 0)
154
+ queue[0].show();
155
+ },
156
+
157
+ positionPopup: function() {
158
+ var popup = $('#' + this.id);
159
+ popup.css("top", ((window.innerHeight / 2.5) + window.pageYOffset) - (popup[0].clientHeight / 2) + "px");
160
+ popup.css("left", (window.innerWidth / 2) - (popup[0].clientWidth / 2) + "px");
161
+ }
162
+ };
163
+
164
+ return popup;
165
+ })();
166
+ var uiBlocked = false;
167
+ $.blockUI = function(opacity) {
168
+ if (uiBlocked)
169
+ return;
170
+ opacity = opacity ? " style='opacity:" + opacity + ";'" : "";
171
+ $('BODY').prepend($("<div id='mask'" + opacity + "></div>"));
172
+ $('BODY DIV#mask').bind("touchstart", function(e) {
173
+ e.preventDefault();
174
+ });
175
+ $('BODY DIV#mask').bind("touchmove", function(e) {
176
+ e.preventDefault();
177
+ });
178
+ uiBlocked = true
179
+ };
180
+
181
+ $.unblockUI = function() {
182
+ uiBlocked = false;
183
+ $('BODY DIV#mask').unbind("touchstart");
184
+ $('BODY DIV#mask').unbind("touchmove");
185
+ $("BODY DIV#mask").remove();
186
+ };
187
+ /**
188
+ * Here we override the window.alert function due to iOS eating touch events on native alerts
189
+ */
190
+ window.alert = function(text) {
191
+ if(text===null||text===undefined)
192
+ text="null";
193
+ if($("#jQUi").length>0)
194
+ $("#jQUi").popup(text.toString());
195
+ else
196
+ $(document.body).popup(text.toString());
197
+ }
198
+ window.confirm = function(text) {
199
+ throw "Due to iOS eating touch events from native confirms, please use our popup plugin instead";
200
+ }
201
+ })(jq);