opal-rails 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -1
- data/lib/assets/javascripts/opal-jquery.js +376 -240
- data/lib/assets/javascripts/opal-spec-runner.js.rb +1 -1
- data/lib/assets/javascripts/opal-spec.js +299 -268
- data/lib/assets/javascripts/opal.js +992 -1751
- data/lib/opal/rails/version.rb +2 -2
- metadata +13 -13
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/elia/opal-rails.png)](http://travis-ci.org/elia/opal-rails)
|
4
4
|
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/elia/opal-rails)
|
5
5
|
|
6
|
-
_Rails (3.2+) bindings for [Opal
|
6
|
+
_Rails (3.2+) bindings for [Opal Ruby](http://opalrb.org) (v0.3.27) engine._
|
7
7
|
|
8
8
|
|
9
9
|
|
@@ -120,6 +120,19 @@ Then visit `/opal_spec` from your app and **reload at will**.
|
|
120
120
|
![1 examples, 0 failures](http://f.cl.ly/items/001n0V0g0u0v14160W2G/Schermata%2007-2456110%20alle%201.06.29%20am.png)
|
121
121
|
|
122
122
|
|
123
|
+
## (Rails) Caveats
|
124
|
+
|
125
|
+
During eager loading (e.g. in production or test env) Rails loads all `.rb` files inside `app/` thus catching Opal files inside `app/assets` or `app/views`, the workaround for this is to add the following code to `application.rb`
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
# Don't eager load stuff from app/assets and app/views
|
129
|
+
config.before_initialize do
|
130
|
+
config.eager_load_paths = config.eager_load_paths.dup - Dir["#{Rails.root}/app/{assets,views}"]
|
131
|
+
end
|
132
|
+
```
|
133
|
+
|
134
|
+
**NOTE:** Rails does not do this on purpose, but the paths system (which states no eager loading for assets/views) is caught in a corner case here. I opened [an issue](rails/rails#???) on Rails already.
|
135
|
+
|
123
136
|
|
124
137
|
|
125
138
|
## License
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// lib/opal-jquery/document.rb
|
2
2
|
(function() {
|
3
|
-
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice,
|
3
|
+
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __module = __opal.module;
|
4
4
|
|
5
5
|
return (function(__base){
|
6
6
|
// line 1, opal-jquery/document, module Document
|
@@ -56,247 +56,90 @@
|
|
56
56
|
|
57
57
|
return nil;
|
58
58
|
|
59
|
-
};
|
60
|
-
;Document._sdonate(["$[]", "$find", "$id", "$parse", "$ready?"]);
|
61
|
-
})(self)
|
62
|
-
})();
|
63
|
-
// lib/opal-jquery/http.rb
|
64
|
-
(function() {
|
65
|
-
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __mm = __opal.mm, __klass = __opal.klass, __hash = __opal.hash;
|
66
|
-
|
67
|
-
return (function(__base, __super){
|
68
|
-
// line 7, opal-jquery/http, class HTTP
|
69
|
-
function HTTP() {};
|
70
|
-
HTTP = __klass(__base, __super, "HTTP", HTTP);
|
71
|
-
var HTTP_prototype = HTTP.prototype, __scope = HTTP._scope, TMP_1, TMP_2, TMP_3, TMP_4;
|
72
|
-
HTTP_prototype.body = HTTP_prototype.error_message = HTTP_prototype.method = HTTP_prototype.status_code = HTTP_prototype.url = HTTP_prototype.errback = HTTP_prototype.json = HTTP_prototype.ok = HTTP_prototype.settings = HTTP_prototype.callback = nil;
|
73
|
-
|
74
|
-
// line 8, opal-jquery/http, HTTP#body
|
75
|
-
HTTP_prototype.$body = function() {
|
76
|
-
|
77
|
-
return this.body
|
78
|
-
};
|
79
|
-
|
80
|
-
// line 9, opal-jquery/http, HTTP#error_message
|
81
|
-
HTTP_prototype.$error_message = function() {
|
82
|
-
|
83
|
-
return this.error_message
|
84
|
-
};
|
85
|
-
|
86
|
-
// line 10, opal-jquery/http, HTTP#method
|
87
|
-
HTTP_prototype.$method = function() {
|
88
|
-
|
89
|
-
return this.method
|
90
|
-
};
|
91
|
-
|
92
|
-
// line 11, opal-jquery/http, HTTP#status_code
|
93
|
-
HTTP_prototype.$status_code = function() {
|
94
|
-
|
95
|
-
return this.status_code
|
96
|
-
};
|
97
|
-
|
98
|
-
// line 12, opal-jquery/http, HTTP#url
|
99
|
-
HTTP_prototype.$url = function() {
|
100
|
-
|
101
|
-
return this.url
|
102
|
-
};
|
103
|
-
|
104
|
-
// line 14, opal-jquery/http, HTTP.get
|
105
|
-
HTTP.$get = TMP_1 = function(url, opts) {
|
106
|
-
var __context, block;
|
107
|
-
block = TMP_1._p || nil, __context = block._s, TMP_1._p = null;
|
108
|
-
if (opts == null) {
|
109
|
-
opts = __hash()
|
110
|
-
}
|
111
|
-
return this['$new'](url, "GET", opts, block)['$send!']()
|
112
|
-
};
|
113
|
-
|
114
|
-
// line 18, opal-jquery/http, HTTP.post
|
115
|
-
HTTP.$post = TMP_2 = function(url, opts) {
|
116
|
-
var __context, block;
|
117
|
-
block = TMP_2._p || nil, __context = block._s, TMP_2._p = null;
|
118
|
-
if (opts == null) {
|
119
|
-
opts = __hash()
|
120
|
-
}
|
121
|
-
return this['$new'](url, "POST", opts, block)['$send!']()
|
122
|
-
};
|
123
|
-
|
124
|
-
// line 22, opal-jquery/http, HTTP#initialize
|
125
|
-
HTTP_prototype.$initialize = function(url, method, options, handler) {
|
126
|
-
var http = nil, settings = nil;if (handler == null) {
|
127
|
-
handler = nil
|
128
|
-
}
|
129
|
-
this.url = url;
|
130
|
-
this.method = method;
|
131
|
-
this.ok = true;
|
132
|
-
http = this;
|
133
|
-
settings = options.$to_native();
|
134
|
-
if (handler !== false && handler !== nil) {
|
135
|
-
this.callback = this.errback = handler
|
136
|
-
};
|
137
|
-
|
138
|
-
settings.data = settings.payload;
|
139
|
-
settings.url = url;
|
140
|
-
settings.type = method;
|
141
|
-
|
142
|
-
settings.success = function(str) {
|
143
|
-
http.body = str;
|
144
|
-
|
145
|
-
if (typeof(str) === 'object') {
|
146
|
-
http.json = __scope.JSON.$from_object(str);
|
147
|
-
}
|
148
|
-
|
149
|
-
return http.$succeed();
|
150
|
-
};
|
151
|
-
|
152
|
-
settings.error = function(xhr, str) {
|
153
|
-
return http.$fail();
|
154
|
-
};
|
155
|
-
|
156
|
-
return this.settings = settings;
|
157
59
|
};
|
158
60
|
|
159
|
-
// line
|
160
|
-
|
161
|
-
var __context, block;
|
162
|
-
block = TMP_3._p || nil, __context = block._s, TMP_3._p = null;
|
61
|
+
// line 40, opal-jquery/document, Document.title
|
62
|
+
Document.$title = function() {
|
163
63
|
|
164
|
-
|
165
|
-
return this;
|
64
|
+
return document.title;
|
166
65
|
};
|
167
66
|
|
168
|
-
// line
|
169
|
-
|
170
|
-
var __context, block;
|
171
|
-
block = TMP_4._p || nil, __context = block._s, TMP_4._p = null;
|
67
|
+
// line 44, opal-jquery/document, Document.title=
|
68
|
+
Document['$title='] = function(title) {
|
172
69
|
|
173
|
-
|
174
|
-
return this;
|
175
|
-
};
|
176
|
-
|
177
|
-
// line 66, opal-jquery/http, HTTP#fail
|
178
|
-
HTTP_prototype.$fail = function() {
|
179
|
-
var __a;
|
180
|
-
this.ok = false;
|
181
|
-
if ((__a = this.errback) !== false && __a !== nil) {
|
182
|
-
return this.errback.$call(this)
|
183
|
-
} else {
|
184
|
-
return nil
|
185
|
-
};
|
70
|
+
return document.title = title;
|
186
71
|
};
|
187
|
-
|
188
|
-
|
189
|
-
HTTP_prototype.$json = function() {
|
190
|
-
var __a;
|
191
|
-
return ((__a = this.json), __a !== false && __a !== nil ? __a : __scope.JSON.$parse(this.body));
|
192
|
-
};
|
193
|
-
|
194
|
-
// line 98, opal-jquery/http, HTTP#ok?
|
195
|
-
HTTP_prototype['$ok?'] = function() {
|
196
|
-
|
197
|
-
return this.ok;
|
198
|
-
};
|
199
|
-
|
200
|
-
// line 105, opal-jquery/http, HTTP#send!
|
201
|
-
HTTP_prototype['$send!'] = function() {
|
202
|
-
|
203
|
-
$.ajax(this.settings);
|
204
|
-
return this;
|
205
|
-
};
|
206
|
-
|
207
|
-
// line 110, opal-jquery/http, HTTP#succeed
|
208
|
-
HTTP_prototype.$succeed = function() {
|
209
|
-
var __a;
|
210
|
-
if ((__a = this.callback) !== false && __a !== nil) {
|
211
|
-
return this.callback.$call(this)
|
212
|
-
} else {
|
213
|
-
return nil
|
214
|
-
};
|
215
|
-
};
|
216
|
-
;HTTP._donate(["$body", "$error_message", "$method", "$status_code", "$url", "$initialize", "$callback", "$errback", "$fail", "$json", "$ok?", "$send!", "$succeed"]); ;HTTP._sdonate(["$get", "$post"]);
|
217
|
-
})(self, null)
|
72
|
+
;Document._sdonate(["$[]", "$find", "$id", "$parse", "$ready?", "$title", "$title="]);
|
73
|
+
})(self)
|
218
74
|
})();
|
219
|
-
// lib/opal-jquery/
|
75
|
+
// lib/opal-jquery/element.rb
|
220
76
|
(function() {
|
221
|
-
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice,
|
222
|
-
|
77
|
+
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __klass = __opal.klass;
|
223
78
|
|
224
|
-
var fn;
|
225
|
-
|
226
|
-
if (typeof(jQuery) !== 'undefined') {
|
227
|
-
fn = jQuery;
|
228
|
-
}
|
229
|
-
else if (typeof(Zepto) !== 'undefined') {
|
230
|
-
fn = Zepto.fn.constructor;
|
231
|
-
}
|
232
|
-
else {
|
233
|
-
self.$raise("no DOM library found");
|
234
|
-
}
|
235
|
-
|
236
79
|
return (function(__base, __super){
|
237
|
-
// line
|
238
|
-
function
|
239
|
-
|
240
|
-
var
|
80
|
+
// line 3, opal-jquery/element, class Element
|
81
|
+
function Element() {};
|
82
|
+
Element = __klass(__base, __super, "Element", Element);
|
83
|
+
var Element_prototype = Element.prototype, __scope = Element._scope, TMP_1, TMP_2;
|
241
84
|
|
242
|
-
// line
|
243
|
-
|
85
|
+
// line 4, opal-jquery/element, Element.find
|
86
|
+
Element.$find = function(selector) {
|
244
87
|
|
245
88
|
return $(selector);
|
246
89
|
};
|
247
90
|
|
248
|
-
// line
|
249
|
-
|
91
|
+
// line 8, opal-jquery/element, Element.id
|
92
|
+
Element.$id = function(id) {
|
250
93
|
|
251
94
|
return __scope.Document.$id(id)
|
252
95
|
};
|
253
96
|
|
254
|
-
// line
|
255
|
-
|
97
|
+
// line 12, opal-jquery/element, Element.new
|
98
|
+
Element.$new = function(tag) {
|
256
99
|
if (tag == null) {
|
257
100
|
tag = "div"
|
258
101
|
}
|
259
102
|
return $(document.createElement(tag));
|
260
103
|
};
|
261
104
|
|
262
|
-
// line
|
263
|
-
|
105
|
+
// line 16, opal-jquery/element, Element.parse
|
106
|
+
Element.$parse = function(str) {
|
264
107
|
|
265
108
|
return $(str);
|
266
109
|
};
|
267
110
|
|
268
|
-
// line
|
269
|
-
|
111
|
+
// line 20, opal-jquery/element, Element#[]
|
112
|
+
Element_prototype['$[]'] = function(name) {
|
270
113
|
|
271
114
|
return this.attr(name) || "";
|
272
115
|
};
|
273
116
|
|
274
|
-
|
117
|
+
Element_prototype['$[]='] = Element_prototype.attr;
|
275
118
|
|
276
|
-
|
119
|
+
Element_prototype['$<<'] = Element_prototype.append;
|
277
120
|
|
278
|
-
|
121
|
+
Element_prototype.$add_class = Element_prototype.addClass;
|
279
122
|
|
280
|
-
|
123
|
+
Element_prototype.$after = Element_prototype.after;
|
281
124
|
|
282
|
-
|
125
|
+
Element_prototype.$append = Element_prototype['$<<'];
|
283
126
|
|
284
|
-
|
127
|
+
Element_prototype.$append_to = Element_prototype.appendTo;
|
285
128
|
|
286
|
-
// line
|
287
|
-
|
129
|
+
// line 73, opal-jquery/element, Element#append_to_body
|
130
|
+
Element_prototype.$append_to_body = function() {
|
288
131
|
|
289
132
|
return this.appendTo(document.body);
|
290
133
|
};
|
291
134
|
|
292
|
-
// line
|
293
|
-
|
135
|
+
// line 77, opal-jquery/element, Element#append_to_head
|
136
|
+
Element_prototype.$append_to_head = function() {
|
294
137
|
|
295
138
|
return this.appendTo(document.head);
|
296
139
|
};
|
297
140
|
|
298
|
-
// line
|
299
|
-
|
141
|
+
// line 93, opal-jquery/element, Element#at
|
142
|
+
Element_prototype.$at = function(index) {
|
300
143
|
|
301
144
|
|
302
145
|
var length = this.length;
|
@@ -313,12 +156,12 @@
|
|
313
156
|
|
314
157
|
};
|
315
158
|
|
316
|
-
|
159
|
+
Element_prototype.$before = Element_prototype.before;
|
317
160
|
|
318
|
-
|
161
|
+
Element_prototype.$children = Element_prototype.children;
|
319
162
|
|
320
|
-
// line
|
321
|
-
|
163
|
+
// line 146, opal-jquery/element, Element#class_name
|
164
|
+
Element_prototype.$class_name = function() {
|
322
165
|
|
323
166
|
|
324
167
|
var first = this[0];
|
@@ -331,8 +174,8 @@
|
|
331
174
|
|
332
175
|
};
|
333
176
|
|
334
|
-
// line
|
335
|
-
|
177
|
+
// line 168, opal-jquery/element, Element#class_name=
|
178
|
+
Element_prototype['$class_name='] = function(name) {
|
336
179
|
|
337
180
|
|
338
181
|
for (var i = 0, length = this.length; i < length; i++) {
|
@@ -342,10 +185,10 @@
|
|
342
185
|
return this;
|
343
186
|
};
|
344
187
|
|
345
|
-
|
188
|
+
Element_prototype.$css = Element_prototype.css;
|
346
189
|
|
347
|
-
// line
|
348
|
-
|
190
|
+
// line 203, opal-jquery/element, Element#each
|
191
|
+
Element_prototype.$each = TMP_1 = function() {
|
349
192
|
var __context, __yield;
|
350
193
|
__yield = TMP_1._p || nil, __context = __yield._s, TMP_1._p = null;
|
351
194
|
|
@@ -355,26 +198,28 @@
|
|
355
198
|
return this;
|
356
199
|
};
|
357
200
|
|
358
|
-
|
201
|
+
Element_prototype.$find = Element_prototype.find;
|
359
202
|
|
360
|
-
// line
|
361
|
-
|
203
|
+
// line 223, opal-jquery/element, Element#first
|
204
|
+
Element_prototype.$first = function() {
|
362
205
|
|
363
206
|
return this.length ? this.first() : nil;
|
364
207
|
};
|
365
208
|
|
366
|
-
|
209
|
+
Element_prototype.$focus = Element_prototype.focus;
|
210
|
+
|
211
|
+
Element_prototype['$has_class?'] = Element_prototype.hasClass;
|
367
212
|
|
368
|
-
// line
|
369
|
-
|
213
|
+
// line 231, opal-jquery/element, Element#html
|
214
|
+
Element_prototype.$html = function() {
|
370
215
|
|
371
216
|
return this.html() || "";
|
372
217
|
};
|
373
218
|
|
374
|
-
|
219
|
+
Element_prototype['$html='] = Element_prototype.html;
|
375
220
|
|
376
|
-
// line
|
377
|
-
|
221
|
+
// line 237, opal-jquery/element, Element#id
|
222
|
+
Element_prototype.$id = function() {
|
378
223
|
|
379
224
|
|
380
225
|
var first = this[0];
|
@@ -387,8 +232,8 @@
|
|
387
232
|
|
388
233
|
};
|
389
234
|
|
390
|
-
// line
|
391
|
-
|
235
|
+
// line 249, opal-jquery/element, Element#id=
|
236
|
+
Element_prototype['$id='] = function(id) {
|
392
237
|
|
393
238
|
|
394
239
|
var first = this[0];
|
@@ -401,8 +246,8 @@
|
|
401
246
|
|
402
247
|
};
|
403
248
|
|
404
|
-
// line
|
405
|
-
|
249
|
+
// line 261, opal-jquery/element, Element#inspect
|
250
|
+
Element_prototype.$inspect = function() {
|
406
251
|
|
407
252
|
|
408
253
|
var val, el, str, result = [];
|
@@ -421,57 +266,304 @@
|
|
421
266
|
|
422
267
|
};
|
423
268
|
|
424
|
-
// line
|
425
|
-
|
269
|
+
// line 279, opal-jquery/element, Element#length
|
270
|
+
Element_prototype.$length = function() {
|
426
271
|
|
427
272
|
return this.length;
|
428
273
|
};
|
429
274
|
|
430
|
-
|
275
|
+
Element_prototype.$next = Element_prototype.next;
|
431
276
|
|
432
|
-
// line
|
433
|
-
|
277
|
+
// line 285, opal-jquery/element, Element#off
|
278
|
+
Element_prototype.$off = function(event_name, selector, handler) {
|
279
|
+
if (handler == null) {
|
280
|
+
handler = nil
|
281
|
+
}
|
282
|
+
|
283
|
+
if (handler === nil) {
|
284
|
+
handler = selector;
|
285
|
+
this.off(event_name, handler._jq);
|
286
|
+
}
|
287
|
+
else {
|
288
|
+
this.off(event_name, selector, handler._jq);
|
289
|
+
}
|
290
|
+
|
291
|
+
return handler;
|
292
|
+
};
|
293
|
+
|
294
|
+
// line 299, opal-jquery/element, Element#on
|
295
|
+
Element_prototype.$on = TMP_2 = function(event_name, selector) {
|
434
296
|
var __context, block;
|
435
297
|
block = TMP_2._p || nil, __context = block._s, TMP_2._p = null;
|
436
|
-
|
298
|
+
if (selector == null) {
|
299
|
+
selector = nil
|
300
|
+
}
|
437
301
|
if (block === nil) {
|
438
302
|
return nil
|
439
303
|
};
|
440
304
|
|
441
|
-
|
442
|
-
|
443
|
-
|
305
|
+
var handler = function(e) { return block.$call(e) };
|
306
|
+
block._jq = handler;
|
307
|
+
|
308
|
+
if (selector === nil) {
|
309
|
+
this.on(event_name, handler);
|
310
|
+
}
|
311
|
+
else {
|
312
|
+
this.on(event_name, selector, handler);
|
313
|
+
}
|
444
314
|
|
445
315
|
return block;
|
446
316
|
};
|
447
317
|
|
448
|
-
|
318
|
+
Element_prototype.$parent = Element_prototype.parent;
|
319
|
+
|
320
|
+
Element_prototype.$prev = Element_prototype.prev;
|
449
321
|
|
450
|
-
|
322
|
+
Element_prototype.$remove = Element_prototype.remove;
|
451
323
|
|
452
|
-
|
324
|
+
Element_prototype.$remove_class = Element_prototype.removeClass;
|
453
325
|
|
454
|
-
|
326
|
+
Element_prototype.$size = Element_prototype.$length;
|
455
327
|
|
456
|
-
|
328
|
+
Element_prototype.$succ = Element_prototype.$next;
|
457
329
|
|
458
|
-
|
330
|
+
Element_prototype['$text='] = Element_prototype.text;
|
459
331
|
|
460
|
-
|
332
|
+
Element_prototype.$toggle_class = Element_prototype.toggleClass;
|
461
333
|
|
462
|
-
|
463
|
-
|
334
|
+
Element_prototype.$trigger = Element_prototype.trigger;
|
335
|
+
|
336
|
+
// line 335, opal-jquery/element, Element#value
|
337
|
+
Element_prototype.$value = function() {
|
464
338
|
|
465
339
|
return this.val() || "";
|
466
340
|
};
|
467
341
|
|
468
|
-
|
469
|
-
;
|
470
|
-
})(self,
|
342
|
+
Element_prototype['$value='] = Element_prototype.val;
|
343
|
+
;Element._sdonate(["$find", "$id", "$new", "$parse"]);
|
344
|
+
})(self, jQuery)
|
345
|
+
})();
|
346
|
+
// lib/opal-jquery/event.rb
|
347
|
+
(function() {
|
348
|
+
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __klass = __opal.klass;
|
349
|
+
|
350
|
+
return (function(__base, __super){
|
351
|
+
// line 1, opal-jquery/event, class Event
|
352
|
+
function Event() {};
|
353
|
+
Event = __klass(__base, __super, "Event", Event);
|
354
|
+
var Event_prototype = Event.prototype, __scope = Event._scope;
|
355
|
+
|
356
|
+
// line 2, opal-jquery/event, Event#current_target
|
357
|
+
Event_prototype.$current_target = function() {
|
358
|
+
|
359
|
+
return $(this.currentTarget);
|
360
|
+
};
|
361
|
+
|
362
|
+
Event_prototype['$default_prevented?'] = Event_prototype.isDefaultPrevented;
|
363
|
+
|
364
|
+
Event_prototype.$prevent_default = Event_prototype.preventDefault;
|
365
|
+
|
366
|
+
// line 10, opal-jquery/event, Event#page_x
|
367
|
+
Event_prototype.$page_x = function() {
|
368
|
+
|
369
|
+
return this.pageX;
|
370
|
+
};
|
371
|
+
|
372
|
+
// line 14, opal-jquery/event, Event#page_y
|
373
|
+
Event_prototype.$page_y = function() {
|
374
|
+
|
375
|
+
return this.pageY;
|
376
|
+
};
|
377
|
+
|
378
|
+
Event_prototype['$propagation_stopped?'] = Event_prototype.propagationStopped;
|
379
|
+
|
380
|
+
Event_prototype.$stop_propagation = Event_prototype.stopPropagation;
|
381
|
+
|
382
|
+
// line 22, opal-jquery/event, Event#target
|
383
|
+
Event_prototype.$target = function() {
|
384
|
+
|
385
|
+
|
386
|
+
if (this._opalTarget) {
|
387
|
+
return this._opalTarget;
|
388
|
+
}
|
389
|
+
|
390
|
+
return this._opalTarget = $(this.target);
|
391
|
+
|
392
|
+
};
|
393
|
+
|
394
|
+
// line 32, opal-jquery/event, Event#type
|
395
|
+
Event_prototype.$type = function() {
|
396
|
+
|
397
|
+
return this.type;
|
398
|
+
};
|
399
|
+
|
400
|
+
// line 36, opal-jquery/event, Event#which
|
401
|
+
Event_prototype.$which = function() {
|
402
|
+
|
403
|
+
return this.which;
|
404
|
+
};
|
405
|
+
|
406
|
+
})(self, $.Event)
|
407
|
+
})();
|
408
|
+
// lib/opal-jquery/http.rb
|
409
|
+
(function() {
|
410
|
+
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __klass = __opal.klass, __hash = __opal.hash;
|
411
|
+
|
412
|
+
return (function(__base, __super){
|
413
|
+
// line 7, opal-jquery/http, class HTTP
|
414
|
+
function HTTP() {};
|
415
|
+
HTTP = __klass(__base, __super, "HTTP", HTTP);
|
416
|
+
var HTTP_prototype = HTTP.prototype, __scope = HTTP._scope, TMP_1, TMP_2, TMP_3, TMP_4;
|
417
|
+
HTTP_prototype.body = HTTP_prototype.error_message = HTTP_prototype.method = HTTP_prototype.status_code = HTTP_prototype.url = HTTP_prototype.errback = HTTP_prototype.json = HTTP_prototype.ok = HTTP_prototype.settings = HTTP_prototype.callback = nil;
|
418
|
+
|
419
|
+
// line 8, opal-jquery/http, HTTP#body
|
420
|
+
HTTP_prototype.$body = function() {
|
421
|
+
|
422
|
+
return this.body
|
423
|
+
};
|
424
|
+
|
425
|
+
// line 9, opal-jquery/http, HTTP#error_message
|
426
|
+
HTTP_prototype.$error_message = function() {
|
427
|
+
|
428
|
+
return this.error_message
|
429
|
+
};
|
430
|
+
|
431
|
+
// line 10, opal-jquery/http, HTTP#method
|
432
|
+
HTTP_prototype.$method = function() {
|
433
|
+
|
434
|
+
return this.method
|
435
|
+
};
|
436
|
+
|
437
|
+
// line 11, opal-jquery/http, HTTP#status_code
|
438
|
+
HTTP_prototype.$status_code = function() {
|
439
|
+
|
440
|
+
return this.status_code
|
441
|
+
};
|
442
|
+
|
443
|
+
// line 12, opal-jquery/http, HTTP#url
|
444
|
+
HTTP_prototype.$url = function() {
|
445
|
+
|
446
|
+
return this.url
|
447
|
+
};
|
448
|
+
|
449
|
+
// line 14, opal-jquery/http, HTTP.get
|
450
|
+
HTTP.$get = TMP_1 = function(url, opts) {
|
451
|
+
var __context, block;
|
452
|
+
block = TMP_1._p || nil, __context = block._s, TMP_1._p = null;
|
453
|
+
if (opts == null) {
|
454
|
+
opts = __hash()
|
455
|
+
}
|
456
|
+
return this.$new(url, "GET", opts, block)['$send!']()
|
457
|
+
};
|
458
|
+
|
459
|
+
// line 18, opal-jquery/http, HTTP.post
|
460
|
+
HTTP.$post = TMP_2 = function(url, opts) {
|
461
|
+
var __context, block;
|
462
|
+
block = TMP_2._p || nil, __context = block._s, TMP_2._p = null;
|
463
|
+
if (opts == null) {
|
464
|
+
opts = __hash()
|
465
|
+
}
|
466
|
+
return this.$new(url, "POST", opts, block)['$send!']()
|
467
|
+
};
|
468
|
+
|
469
|
+
// line 22, opal-jquery/http, HTTP#initialize
|
470
|
+
HTTP_prototype.$initialize = function(url, method, options, handler) {
|
471
|
+
var http = nil, settings = nil;if (handler == null) {
|
472
|
+
handler = nil
|
473
|
+
}
|
474
|
+
this.url = url;
|
475
|
+
this.method = method;
|
476
|
+
this.ok = true;
|
477
|
+
http = this;
|
478
|
+
settings = options.$to_native();
|
479
|
+
if (handler !== false && handler !== nil) {
|
480
|
+
this.callback = this.errback = handler
|
481
|
+
};
|
482
|
+
|
483
|
+
settings.data = settings.payload;
|
484
|
+
settings.url = url;
|
485
|
+
settings.type = method;
|
486
|
+
|
487
|
+
settings.success = function(str) {
|
488
|
+
http.body = str;
|
489
|
+
|
490
|
+
if (typeof(str) === 'object') {
|
491
|
+
http.json = __scope.JSON.$from_object(str);
|
492
|
+
}
|
493
|
+
|
494
|
+
return http.$succeed();
|
495
|
+
};
|
496
|
+
|
497
|
+
settings.error = function(xhr, str) {
|
498
|
+
return http.$fail();
|
499
|
+
};
|
500
|
+
|
501
|
+
return this.settings = settings;
|
502
|
+
};
|
503
|
+
|
504
|
+
// line 56, opal-jquery/http, HTTP#callback
|
505
|
+
HTTP_prototype.$callback = TMP_3 = function() {
|
506
|
+
var __context, block;
|
507
|
+
block = TMP_3._p || nil, __context = block._s, TMP_3._p = null;
|
508
|
+
|
509
|
+
this.callback = block;
|
510
|
+
return this;
|
511
|
+
};
|
512
|
+
|
513
|
+
// line 61, opal-jquery/http, HTTP#errback
|
514
|
+
HTTP_prototype.$errback = TMP_4 = function() {
|
515
|
+
var __context, block;
|
516
|
+
block = TMP_4._p || nil, __context = block._s, TMP_4._p = null;
|
517
|
+
|
518
|
+
this.errback = block;
|
519
|
+
return this;
|
520
|
+
};
|
521
|
+
|
522
|
+
// line 66, opal-jquery/http, HTTP#fail
|
523
|
+
HTTP_prototype.$fail = function() {
|
524
|
+
var __a;
|
525
|
+
this.ok = false;
|
526
|
+
if ((__a = this.errback) !== false && __a !== nil) {
|
527
|
+
return this.errback.$call(this)
|
528
|
+
} else {
|
529
|
+
return nil
|
530
|
+
};
|
531
|
+
};
|
532
|
+
|
533
|
+
// line 83, opal-jquery/http, HTTP#json
|
534
|
+
HTTP_prototype.$json = function() {
|
535
|
+
var __a;
|
536
|
+
return ((__a = this.json), __a !== false && __a !== nil ? __a : __scope.JSON.$parse(this.body));
|
537
|
+
};
|
538
|
+
|
539
|
+
// line 98, opal-jquery/http, HTTP#ok?
|
540
|
+
HTTP_prototype['$ok?'] = function() {
|
541
|
+
|
542
|
+
return this.ok;
|
543
|
+
};
|
544
|
+
|
545
|
+
// line 105, opal-jquery/http, HTTP#send!
|
546
|
+
HTTP_prototype['$send!'] = function() {
|
547
|
+
|
548
|
+
$.ajax(this.settings);
|
549
|
+
return this;
|
550
|
+
};
|
551
|
+
|
552
|
+
// line 110, opal-jquery/http, HTTP#succeed
|
553
|
+
HTTP_prototype.$succeed = function() {
|
554
|
+
var __a;
|
555
|
+
if ((__a = this.callback) !== false && __a !== nil) {
|
556
|
+
return this.callback.$call(this)
|
557
|
+
} else {
|
558
|
+
return nil
|
559
|
+
};
|
560
|
+
};
|
561
|
+
;HTTP._sdonate(["$get", "$post"]);
|
562
|
+
})(self, null)
|
471
563
|
})();
|
472
564
|
// lib/opal-jquery/kernel.rb
|
473
565
|
(function() {
|
474
|
-
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice,
|
566
|
+
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __module = __opal.module;
|
475
567
|
|
476
568
|
return (function(__base){
|
477
569
|
// line 1, opal-jquery/kernel, module Kernel
|
@@ -488,12 +580,56 @@
|
|
488
580
|
;Kernel._donate(["$alert"]);
|
489
581
|
})(self)
|
490
582
|
})();
|
583
|
+
// lib/opal-jquery/local_storage.rb
|
584
|
+
(function() {
|
585
|
+
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __module = __opal.module;
|
586
|
+
|
587
|
+
return (function(__base){
|
588
|
+
// line 1, opal-jquery/local_storage, module LocalStorage
|
589
|
+
function LocalStorage() {};
|
590
|
+
LocalStorage = __module(__base, "LocalStorage", LocalStorage);
|
591
|
+
var LocalStorage_prototype = LocalStorage.prototype, __scope = LocalStorage._scope;
|
592
|
+
|
593
|
+
// line 2, opal-jquery/local_storage, LocalStorage.[]
|
594
|
+
LocalStorage['$[]'] = function(key) {
|
595
|
+
|
596
|
+
|
597
|
+
var val = localStorage.getItem(key);
|
598
|
+
return val === null ? nil : val;
|
599
|
+
|
600
|
+
};
|
601
|
+
|
602
|
+
// line 9, opal-jquery/local_storage, LocalStorage.[]=
|
603
|
+
LocalStorage['$[]='] = function(key, value) {
|
604
|
+
|
605
|
+
return localStorage.setItem(key, value);
|
606
|
+
};
|
607
|
+
|
608
|
+
// line 13, opal-jquery/local_storage, LocalStorage.clear
|
609
|
+
LocalStorage.$clear = function() {
|
610
|
+
|
611
|
+
localStorage.clear();
|
612
|
+
return this;
|
613
|
+
};
|
614
|
+
|
615
|
+
// line 18, opal-jquery/local_storage, LocalStorage.delete
|
616
|
+
LocalStorage.$delete = function(key) {
|
617
|
+
|
618
|
+
|
619
|
+
var val = localStorage.getItem(key);
|
620
|
+
localStorage.removeItem(key);
|
621
|
+
return val === null ? nil : val;
|
622
|
+
|
623
|
+
};
|
624
|
+
;LocalStorage._sdonate(["$[]", "$[]=", "$clear", "$delete"]);
|
625
|
+
})(self)
|
626
|
+
})();
|
491
627
|
// lib/opal-jquery.rb
|
492
628
|
(function() {
|
493
|
-
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice
|
629
|
+
var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice;
|
494
630
|
|
495
631
|
//= require opal-jquery/document;
|
496
|
-
//= require opal-jquery/
|
632
|
+
//= require opal-jquery/element;
|
497
633
|
//= require opal-jquery/kernel;
|
498
634
|
return //= require opal-jquery/http;
|
499
635
|
})();
|