opal-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,654 @@
1
+ // file lib/opal/dom/depreceated.rb
2
+ (function() {
3
+ var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __klass = __opal.klass;
4
+
5
+ return (function(__base, __super){
6
+ // line 1, lib/opal/dom/depreceated.rb, class DOM
7
+ function DOM() {};
8
+ DOM = __klass(__base, __super, "DOM", DOM);
9
+ var DOM_prototype = DOM.prototype, __scope = DOM._scope;
10
+
11
+ // line 2, lib/opal/dom/depreceated.rb, DOM.parse
12
+ DOM.$parse = function(str) {
13
+
14
+
15
+ var el = document.createElement('div');
16
+ // awkward IE
17
+ el.innerHTML = "_" + str;
18
+
19
+ var child = el.firstChild;
20
+
21
+ while (child) {
22
+ if (child.nodeType !== 1) {
23
+ child = child.nextSibling
24
+ continue;
25
+ }
26
+
27
+ return __scope.Element.$new(child)
28
+ }
29
+
30
+ this.$raise("no DOM node in content")
31
+
32
+ }
33
+ ;DOM._sdonate(["$parse"]);
34
+ })(self, null)
35
+ })();
36
+ // file lib/opal/dom/document.rb
37
+ (function() {
38
+ var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __module = __opal.module;
39
+
40
+ return (function(__base){
41
+ // line 1, lib/opal/dom/document.rb, module Document
42
+ function Document() {};
43
+ Document = __module(__base, "Document", Document);
44
+ var Document_prototype = Document.prototype, __scope = Document._scope, TMP_1;
45
+
46
+ // line 2, lib/opal/dom/document.rb, Document.body_ready?
47
+ Document.$body_ready$p = function() {
48
+
49
+ return !!(document && document.body);
50
+ };
51
+
52
+ // line 6, lib/opal/dom/document.rb, Document.ready?
53
+ Document.$ready$p = TMP_1 = function() {
54
+ var __context, block;
55
+ block = TMP_1._p || nil, __context = block._s, TMP_1._p = null;
56
+
57
+ setTimeout(function() { block.call(block._s); }, 0)
58
+ };
59
+ ;Document._sdonate(["$body_ready$p", "$ready$p"]);
60
+ })(self)
61
+ })();
62
+ // file lib/opal/dom/element.rb
63
+ (function() {
64
+ var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __klass = __opal.klass;
65
+
66
+ return (function(__base, __super){
67
+ // line 1, lib/opal/dom/element.rb, class Element
68
+ function Element() {};
69
+ Element = __klass(__base, __super, "Element", Element);
70
+ var supports_inner_html = nil, Element_prototype = Element.prototype, __scope = Element._scope, __a;
71
+
72
+ // line 5, lib/opal/dom/element.rb, Element.[]
73
+ Element.$aref$ = function(str) {
74
+
75
+ return this.$Element(str)
76
+ };
77
+
78
+ // line 27, lib/opal/dom/element.rb, Element#initialize
79
+ Element_prototype.$initialize = function(el) {
80
+ if (el == null) {
81
+ el = "div"
82
+ }
83
+
84
+ if (typeof(el) === 'string') {
85
+ el = document.createElement(el);
86
+ }
87
+
88
+ if (!el || !el.nodeType) {
89
+ throw new Error('not a valid element');
90
+ }
91
+
92
+ this.el = el;
93
+
94
+ };
95
+
96
+ // line 41, lib/opal/dom/element.rb, Element#<<
97
+ Element_prototype.$lshft$ = function(content) {
98
+
99
+ return this.el.appendChild(content.el);
100
+ };
101
+
102
+ Element_prototype.$append = Element_prototype.$lshft$;
103
+
104
+ // line 47, lib/opal/dom/element.rb, Element#append_to_body
105
+ Element_prototype.$append_to_body = function() {
106
+
107
+
108
+ document.body.appendChild(this.el);
109
+ return this;
110
+
111
+ };
112
+
113
+ // line 54, lib/opal/dom/element.rb, Element#append_to_head
114
+ Element_prototype.$append_to_head = function() {
115
+
116
+
117
+ document.getElementsByTagName('head')[0].appendChild(this.el);
118
+ return this;
119
+
120
+ };
121
+
122
+ // line 70, lib/opal/dom/element.rb, Element#add_class
123
+ Element_prototype.$add_class = function(name) {
124
+
125
+
126
+ var el = this.el, className = el.className;
127
+
128
+ if (!className) {
129
+ el.className = name;
130
+ }
131
+ else if((' ' + className + ' ').indexOf(' ' + name + ' ') === -1) {
132
+ el.className += (' ' + name);
133
+ }
134
+
135
+ return this;
136
+
137
+ };
138
+
139
+ // line 97, lib/opal/dom/element.rb, Element#has_class?
140
+ Element_prototype.$has_class$p = function(name) {
141
+
142
+ return (' ' + this.el.className + ' ').indexOf(' ' + name + ' ') !== -1;
143
+ };
144
+
145
+ // line 101, lib/opal/dom/element.rb, Element#id
146
+ Element_prototype.$id = function() {
147
+
148
+ return this.el.id;
149
+ };
150
+
151
+ // line 105, lib/opal/dom/element.rb, Element#inspect
152
+ Element_prototype.$inspect = function() {
153
+
154
+
155
+ var val, el = this.el, str = '<' + el.tagName.toLowerCase();
156
+
157
+ if (val = el.id) str += (' id="' + val + '"');
158
+ if (val = el.className) str += (' class="' + val + '"');
159
+
160
+ return str + '>';
161
+
162
+ };
163
+
164
+ // line 116, lib/opal/dom/element.rb, Element#class_name
165
+ Element_prototype.$class_name = function() {
166
+
167
+
168
+ return this.el.className || '';
169
+
170
+ };
171
+
172
+ // line 122, lib/opal/dom/element.rb, Element#class_name=
173
+ Element_prototype.$class_name$e = function(name) {
174
+
175
+
176
+ return this.el.className = name;
177
+
178
+ };
179
+
180
+ // line 137, lib/opal/dom/element.rb, Element#next
181
+ Element_prototype.$next = function() {
182
+
183
+ return this.$sibling("nextSibling");
184
+ };
185
+
186
+ // line 150, lib/opal/dom/element.rb, Element#prev
187
+ Element_prototype.$prev = function() {
188
+
189
+ return this.$sibling("previousSibling");
190
+ };
191
+
192
+ // line 163, lib/opal/dom/element.rb, Element#remove_class
193
+ Element_prototype.$remove_class = function(name) {
194
+
195
+
196
+ var el = this.el, className = ' ' + el.className + ' ';
197
+
198
+ className = className.replace(' ' + name + ' ', ' ');
199
+ className = className.replace(/^\s+/, '').replace(/\s+$/, '');
200
+
201
+ el.className = className;
202
+
203
+ return this;
204
+
205
+ };
206
+
207
+ // line 176, lib/opal/dom/element.rb, Element#remove
208
+ Element_prototype.$remove = function() {
209
+
210
+
211
+ var el = this.el, parent = el.parentNode;
212
+
213
+ if (parent) {
214
+ parent.removeChild(el);
215
+ }
216
+
217
+ return this;
218
+
219
+ };
220
+
221
+ // line 189, lib/opal/dom/element.rb, Element#sibling
222
+ Element_prototype.$sibling = function(type) {
223
+
224
+
225
+ var el = this.el;
226
+
227
+ while (el = el[type]) {
228
+ if (el.nodeType !== 1) {
229
+ continue;
230
+ }
231
+
232
+ return __scope.Element.$new(el)
233
+ }
234
+
235
+ return nil;
236
+
237
+ };
238
+
239
+ Element_prototype.$succ = Element_prototype.$next;
240
+
241
+ // line 207, lib/opal/dom/element.rb, Element#hide
242
+ Element_prototype.$hide = function() {
243
+
244
+
245
+ this.el.style.display = 'none';
246
+ return this;
247
+
248
+ };
249
+
250
+ // line 214, lib/opal/dom/element.rb, Element#show
251
+ Element_prototype.$show = function() {
252
+
253
+
254
+ this.el.style.display = '';
255
+ return this;
256
+
257
+ };
258
+
259
+ // line 228, lib/opal/dom/element.rb, Element#clear
260
+ Element_prototype.$clear = function() {
261
+
262
+
263
+ var el = this.el;
264
+
265
+ while (el.firstChild) {
266
+ el.removeChild(el.firstChild);
267
+ }
268
+
269
+ return this;
270
+
271
+ };
272
+
273
+ // line 240, lib/opal/dom/element.rb, Element#css
274
+ Element_prototype.$css = function(name, value) {
275
+
276
+
277
+ if (value == null) {
278
+ return this.el.style[name];
279
+ }
280
+
281
+ return this.el.style[name] = value;
282
+
283
+ };
284
+
285
+ // line 258, lib/opal/dom/element.rb, Element#html
286
+ Element_prototype.$html = function() {
287
+
288
+ return this.el.innerHTML;
289
+ };
290
+
291
+ // line 272, lib/opal/dom/element.rb, Element#html=
292
+ Element_prototype.$html$e = function(html) {
293
+
294
+
295
+ this.el.innerHTML = html;
296
+
297
+ return this;
298
+
299
+ };
300
+
301
+ supports_inner_html = true;
302
+
303
+
304
+ try {
305
+ var table = document.createElement('table');
306
+ table.innerHTML = "<tr><td></td></tr>";
307
+ } catch (err) {
308
+ supports_inner_html = false;
309
+ }
310
+
311
+
312
+ if ((__a = supports_inner_html) === false || __a === nil) {
313
+ // line 293, lib/opal/dom/element.rb, Element#html=
314
+ Element_prototype.$html$e = function(html) {
315
+
316
+ this.el.innerHTML = html;
317
+ return this;
318
+ }
319
+ };
320
+
321
+ // line 301, lib/opal/dom/element.rb, Element#text
322
+ Element_prototype.$text = function() {
323
+
324
+ return text_value(this.el);
325
+ };
326
+
327
+ // line 305, lib/opal/dom/element.rb, Element#text=
328
+ Element_prototype.$text$e = function(str) {
329
+
330
+ this.$clear();
331
+ this.el.appendChild(document.createTextNode(str));
332
+ return this;
333
+ };
334
+
335
+
336
+ function text_value(el) {
337
+ var type = el.nodeType, result = '';
338
+
339
+ if (type === 1 || type === 9 || type === 11) {
340
+ if (typeof(el.textContent) === 'string') {
341
+ return el.textContent;
342
+ }
343
+ else if (typeof(el.innerText) === 'string') {
344
+ return el.innerText.replace(/\r/g, '');
345
+ }
346
+ else {
347
+ for (var c = el.firstChild; c; c = c.nextSibling) {
348
+ result += text_value(c);
349
+ }
350
+ }
351
+ }
352
+ else if (type === 3 || type === 4) {
353
+ return el.nodeValue;
354
+ }
355
+
356
+ return result;
357
+ }
358
+
359
+ ;Element._donate(["$initialize", "$lshft$", "$append", "$append_to_body", "$append_to_head", "$add_class", "$has_class$p", "$id", "$inspect", "$class_name", "$class_name$e", "$next", "$prev", "$remove_class", "$remove", "$sibling", "$succ", "$hide", "$show", "$clear", "$css", "$html", "$html$e", "$html$e", "$text", "$text$e"]); ;Element._sdonate(["$aref$"]);
360
+ })(self, null)
361
+ })();
362
+ // file lib/opal/dom/element_set.rb
363
+ (function() {
364
+ var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __klass = __opal.klass;
365
+
366
+ return (function(__base, __super){
367
+ // line 11, lib/opal/dom/element_set.rb, class ElementSet
368
+ function ElementSet() {};
369
+ ElementSet = __klass(__base, __super, "ElementSet", ElementSet);
370
+ var ElementSet_prototype = ElementSet.prototype, __scope = ElementSet._scope, TMP_1;
371
+
372
+ // line 19, lib/opal/dom/element_set.rb, ElementSet#initialize
373
+ ElementSet_prototype.$initialize = function(selector, context) {
374
+
375
+ return this.length = 0;
376
+ };
377
+
378
+ // line 24, lib/opal/dom/element_set.rb, ElementSet#each
379
+ ElementSet_prototype.$each = TMP_1 = function() {
380
+ var __context, block;
381
+ block = TMP_1._p || nil, __context = block._s, TMP_1._p = null;
382
+
383
+ for (var i = 0, length = this.length; i < length; i++) {
384
+ if (block.call(__context, this[i]) === __breaker) return __breaker.$v;
385
+ };
386
+ return this;
387
+ };
388
+
389
+ // line 32, lib/opal/dom/element_set.rb, ElementSet#length
390
+ ElementSet_prototype.$length = function() {
391
+
392
+ return this.length;
393
+ };
394
+
395
+ ElementSet_prototype.$size = ElementSet_prototype.$length;
396
+ ;ElementSet._donate(["$initialize", "$each", "$length", "$size"]);
397
+ })(self, null)
398
+ })();
399
+ // file lib/opal/dom/event.rb
400
+ (function() {
401
+ var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __klass = __opal.klass;
402
+
403
+ return (function(__base, __super){
404
+ // line 1, lib/opal/dom/event.rb, class Event
405
+ function Event() {};
406
+ Event = __klass(__base, __super, "Event", Event);
407
+ var Event_prototype = Event.prototype, __scope = Event._scope;
408
+ Event_prototype.alt = Event_prototype.ctrl = Event_prototype.meta = Event_prototype.shift = nil;
409
+
410
+ // line 2, lib/opal/dom/event.rb, Event#initialize
411
+ Event_prototype.$initialize = function(evt) {
412
+
413
+
414
+ this.evt = evt;
415
+
416
+ this.alt = evt.altKey;
417
+ this.ctrl = evt.ctrlKey;
418
+ this.meta = evt.metaKey;
419
+ this.shift = evt.shiftKey;
420
+
421
+ };
422
+
423
+ // line 13, lib/opal/dom/event.rb, Event#alt?
424
+ Event_prototype.$alt$p = function() {
425
+
426
+ return this.alt;
427
+ };
428
+
429
+ // line 17, lib/opal/dom/event.rb, Event#ctrl?
430
+ Event_prototype.$ctrl$p = function() {
431
+
432
+ return this.ctrl;
433
+ };
434
+
435
+ // line 21, lib/opal/dom/event.rb, Event#meta?
436
+ Event_prototype.$meta$p = function() {
437
+
438
+ return this.meta;
439
+ };
440
+
441
+ // line 35, lib/opal/dom/event.rb, Event#stop
442
+ Event_prototype.$stop = function() {
443
+
444
+ this.$prevent_default();
445
+ return this.$stop_propagation();
446
+ };
447
+
448
+ // line 40, lib/opal/dom/event.rb, Event#prevent_default
449
+ Event_prototype.$prevent_default = function() {
450
+
451
+
452
+ var evt = this.evt;
453
+
454
+ if (evt.preventDefault) {
455
+ evt.preventDefault()
456
+ }
457
+ else {
458
+ evt.returnValue = false;
459
+ }
460
+
461
+ return this;
462
+
463
+ };
464
+
465
+ // line 55, lib/opal/dom/event.rb, Event#shift?
466
+ Event_prototype.$shift$p = function() {
467
+
468
+ return this.shift;
469
+ };
470
+
471
+ // line 59, lib/opal/dom/event.rb, Event#stop_propagation
472
+ Event_prototype.$stop_propagation = function() {
473
+
474
+
475
+ var evt = this.evt;
476
+
477
+ if (evt.stopPropagation) {
478
+ evt.stopPropagation();
479
+ }
480
+ else {
481
+ evt.cancelBubble = true;
482
+ }
483
+
484
+ return this;
485
+
486
+ };
487
+ ;Event._donate(["$initialize", "$alt$p", "$ctrl$p", "$meta$p", "$stop", "$prevent_default", "$shift$p", "$stop_propagation"]);
488
+ })(self, null)
489
+ })();
490
+ // file lib/opal/dom/events.rb
491
+ (function() {
492
+ var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __klass = __opal.klass;
493
+
494
+ return (function(__base, __super){
495
+ // line 1, lib/opal/dom/events.rb, class Element
496
+ function Element() {};
497
+ Element = __klass(__base, __super, "Element", Element);
498
+ var Element_prototype = Element.prototype, __scope = Element._scope, __a, __b, TMP_2, TMP_3;
499
+
500
+ __scope.EVENTS = ["click", "mousedown", "mouseup"];
501
+
502
+ (__b = __scope.EVENTS, __b.$each._p = (__a = function(evt) {
503
+
504
+ var TMP_1, __a, __b;
505
+ if (evt == null) evt = nil;
506
+
507
+ return (__b = this, __b.$define_method._p = (__a = TMP_1 = function() {
508
+
509
+ var handler, __context, __a;
510
+
511
+ handler = TMP_1._p || nil, __context = handler._s, TMP_1.p = null;
512
+
513
+ return (__a = this, __a.$add_listener._p = handler.$to_proc(), __a.$add_listener(evt))
514
+ }, __a._s = this, __a), __b.$define_method(evt))
515
+ }, __a._s = Element, __a), __b.$each());
516
+
517
+ // line 49, lib/opal/dom/events.rb, Element#add_listener
518
+ Element_prototype.$add_listener = TMP_2 = function(type) {
519
+ var __context, handler;
520
+ handler = TMP_2._p || nil, __context = handler._s, TMP_2._p = null;
521
+
522
+
523
+ var el = this.el, responder = function(event) {
524
+ if (!event) {
525
+ var event = window.event;
526
+ }
527
+ var evt = __scope.Event.$new(event);
528
+ return handler.call(handler._s, evt);
529
+ };
530
+
531
+ if (el.addEventListener) {
532
+ el.addEventListener(type, responder, false);
533
+ }
534
+ else if (el.attachEvent) {
535
+ el.attachEvent('on' + type, responder);
536
+ }
537
+
538
+ return handler;
539
+
540
+ };
541
+
542
+ // line 70, lib/opal/dom/events.rb, Element#remove_listener
543
+ Element_prototype.$remove_listener = TMP_3 = function(type) {
544
+ var __context, handler;
545
+ handler = TMP_3._p || nil, __context = handler._s, TMP_3._p = null;
546
+
547
+ return nil;
548
+ };
549
+ ;Element._donate(["$add_listener", "$remove_listener"]);
550
+ })(self, null)
551
+ })();
552
+ // file lib/opal/dom/http.rb
553
+ (function() {
554
+ var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __klass = __opal.klass;
555
+
556
+ return (function(__base, __super){
557
+ // line 1, lib/opal/dom/http.rb, class HTTP
558
+ function HTTP() {};
559
+ HTTP = __klass(__base, __super, "HTTP", HTTP);
560
+ var HTTP_prototype = HTTP.prototype, __scope = HTTP._scope;
561
+
562
+
563
+ var make_xhr = function() {
564
+ if (typeof XMLHttpRequest !== 'undefined' && (window.location.protocol !== 'file:' || !window.ActiveXObject)) {
565
+ return new XMLHttpRequest();
566
+ } else {
567
+ try {
568
+ return new ActiveXObject('Msxml2.XMLHTTP.6.0');
569
+ } catch(e) { }
570
+ try {
571
+ return new ActiveXObject('Msxml2.XMLHTTP.3.0');
572
+ } catch(e) { }
573
+ try {
574
+ return new ActiveXObject('Msxml2.XMLHTTP');
575
+ } catch(e) { }
576
+ }
577
+
578
+ HTTP.$raise("Cannot make request");
579
+ }
580
+
581
+
582
+ // line 22, lib/opal/dom/http.rb, HTTP#initialize
583
+ HTTP_prototype.$initialize = function() {
584
+
585
+
586
+ this.xhr = make_xhr();
587
+
588
+ };
589
+
590
+ // line 28, lib/opal/dom/http.rb, HTTP#ok?
591
+ HTTP_prototype.$ok$p = function() {
592
+
593
+ return this.status >= 200 && this.status < 300;
594
+ };
595
+ ;HTTP._donate(["$initialize", "$ok$p"]);
596
+ })(self, null)
597
+ })();
598
+ // file lib/opal/dom/kernel.rb
599
+ (function() {
600
+ var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __module = __opal.module;
601
+
602
+ return (function(__base){
603
+ // line 1, lib/opal/dom/kernel.rb, module Kernel
604
+ function Kernel() {};
605
+ Kernel = __module(__base, "Kernel", Kernel);
606
+ var Kernel_prototype = Kernel.prototype, __scope = Kernel._scope;
607
+
608
+ // line 13, lib/opal/dom/kernel.rb, Kernel#Element
609
+ Kernel_prototype.$Element = function(selector) {
610
+
611
+
612
+ var el
613
+
614
+ if (selector.charAt(0) === '#') {
615
+ el = document.getElementById(selector.substr(1));
616
+
617
+ if (el) {
618
+ return __scope.Element.$new(el);
619
+ }
620
+ else {
621
+ return nil;
622
+ }
623
+ }
624
+ else {
625
+ return __scope.DOM.$parse(selector)
626
+ }
627
+
628
+ return nil;
629
+
630
+ };
631
+
632
+ // line 43, lib/opal/dom/kernel.rb, Kernel#alert
633
+ Kernel_prototype.$alert = function(msg) {
634
+
635
+ alert(msg);
636
+ return this;
637
+ };
638
+ ;Kernel._donate(["$Element", "$alert"]);
639
+ })(self)
640
+ })();
641
+ // file lib/opal/dom/version.rb
642
+ (function() {
643
+ var __opal = Opal, self = __opal.top, __scope = __opal, nil = __opal.nil, __breaker = __opal.breaker, __slice = __opal.slice, __klass = __opal.klass;
644
+
645
+ return (function(__base, __super){
646
+ // line 1, lib/opal/dom/version.rb, class DOM
647
+ function DOM() {};
648
+ DOM = __klass(__base, __super, "DOM", DOM);
649
+ var DOM_prototype = DOM.prototype, __scope = DOM._scope;
650
+
651
+ __scope.VERSION = "0.0.1"
652
+
653
+ })(self, null)
654
+ })();