goat 0.3.11 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- data/goat.gemspec +1 -1
- data/lib/goat/goat.js +29 -50
- data/lib/goat/js/component.js +1 -1
- metadata +3 -3
data/goat.gemspec
CHANGED
data/lib/goat/goat.js
CHANGED
@@ -1,33 +1,18 @@
|
|
1
1
|
(function(){
|
2
2
|
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
|
3
|
-
// The base Class implementation (does nothing)
|
4
3
|
this.Class = function(){};
|
5
|
-
|
6
|
-
// Create a new Class that inherits from this class
|
7
4
|
Class.extend = function(prop) {
|
8
5
|
var _super = this.prototype;
|
9
|
-
|
10
|
-
// Instantiate a base class (but only create the instance,
|
11
|
-
// don't run the init constructor)
|
12
6
|
initializing = true;
|
13
7
|
var prototype = new this();
|
14
8
|
initializing = false;
|
15
|
-
|
16
|
-
// Copy the properties over onto the new prototype
|
17
9
|
for (var name in prop) {
|
18
|
-
// Check if we're overwriting an existing function
|
19
10
|
prototype[name] = typeof prop[name] == "function" &&
|
20
11
|
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
|
21
12
|
(function(name, fn){
|
22
13
|
return function() {
|
23
14
|
var tmp = this._super;
|
24
|
-
|
25
|
-
// Add a new ._super() method that is the same method
|
26
|
-
// but on the super-class
|
27
15
|
this._super = _super[name];
|
28
|
-
|
29
|
-
// The method only need to be bound temporarily, so we
|
30
|
-
// remove it when we're done executing
|
31
16
|
var ret = fn.apply(this, arguments);
|
32
17
|
this._super = tmp;
|
33
18
|
|
@@ -36,23 +21,14 @@
|
|
36
21
|
})(name, prop[name]) :
|
37
22
|
prop[name];
|
38
23
|
}
|
39
|
-
|
40
|
-
// The dummy class constructor
|
41
24
|
function Class() {
|
42
25
|
// All construction is actually done in the init method
|
43
26
|
if ( !initializing && this.init )
|
44
27
|
this.init.apply(this, arguments);
|
45
28
|
}
|
46
|
-
|
47
|
-
// Populate our constructed prototype object
|
48
29
|
Class.prototype = prototype;
|
49
|
-
|
50
|
-
// Enforce the constructor to be what we expect
|
51
30
|
Class.constructor = Class;
|
52
|
-
|
53
|
-
// And make this class extendable
|
54
31
|
Class.extend = arguments.callee;
|
55
|
-
|
56
32
|
return Class;
|
57
33
|
};
|
58
34
|
})();
|
@@ -67,12 +43,9 @@ String.random = function string_random(len, pref) {
|
|
67
43
|
return pref ? (pref + '_' + str) : str;
|
68
44
|
}
|
69
45
|
|
70
|
-
|
71
|
-
Goat.loadComponents();
|
72
|
-
setTimeout(function() { if(Goat.page_id) Goat.openChannel(); }, 1000);
|
73
|
-
});
|
46
|
+
var Goat = {}
|
74
47
|
|
75
|
-
|
48
|
+
Goat.RT = {
|
76
49
|
version: 0,
|
77
50
|
pendingTxns: {},
|
78
51
|
ops: {},
|
@@ -171,7 +144,7 @@ var GoatRT = {
|
|
171
144
|
}
|
172
145
|
|
173
146
|
function newTxn() {
|
174
|
-
var op = new RTTxn();
|
147
|
+
var op = new Goat.RTTxn();
|
175
148
|
rt.ops[op.code] = op;
|
176
149
|
return op;
|
177
150
|
}
|
@@ -191,7 +164,7 @@ var GoatRT = {
|
|
191
164
|
delete rt.pendingTxns[txn];
|
192
165
|
|
193
166
|
if(pendingCount() == 0) {
|
194
|
-
LoadingIndicator.hide();
|
167
|
+
Goat.LoadingIndicator.hide();
|
195
168
|
}
|
196
169
|
|
197
170
|
if(txn.complete) txn.complete();
|
@@ -213,9 +186,9 @@ var GoatRT = {
|
|
213
186
|
rt.txnCompleteMsg = txnCompleteMsg;
|
214
187
|
|
215
188
|
return rt;
|
216
|
-
})(
|
189
|
+
})(Goat.RT);
|
217
190
|
|
218
|
-
|
191
|
+
Goat.LoadingIndicator = {
|
219
192
|
url: null,
|
220
193
|
indicator: null,
|
221
194
|
where: null,
|
@@ -247,9 +220,9 @@ var LoadingIndicator = {
|
|
247
220
|
ld.hide = hide;
|
248
221
|
|
249
222
|
return ld;
|
250
|
-
})(LoadingIndicator);
|
223
|
+
})(Goat.LoadingIndicator);
|
251
224
|
|
252
|
-
|
225
|
+
Goat.RTTxn = Class.extend({
|
253
226
|
init: function() {
|
254
227
|
this.code = String.random(8, 'txn');
|
255
228
|
},
|
@@ -263,7 +236,7 @@ var RTTxn = Class.extend({
|
|
263
236
|
}
|
264
237
|
});
|
265
238
|
|
266
|
-
|
239
|
+
Goat.RPC = Class.extend({
|
267
240
|
init: function(c, n) {
|
268
241
|
this.component = c;
|
269
242
|
this.name = n;
|
@@ -324,14 +297,14 @@ var GoatRPC = Class.extend({
|
|
324
297
|
data['args'] = JSON.stringify(this.args);
|
325
298
|
|
326
299
|
if(this.rt) {
|
327
|
-
var txn =
|
300
|
+
var txn = Goat.RT.newTxn();
|
328
301
|
data['rttxn'] = txn.code;
|
329
302
|
txn.onComplete(this.updateComplete);
|
330
|
-
|
303
|
+
Goat.RT.beginTxn(txn);
|
331
304
|
}
|
332
305
|
|
333
306
|
if(this.start) this.start()
|
334
|
-
else if(this.rt) LoadingIndicator.show();
|
307
|
+
else if(this.rt) Goat.LoadingIndicator.show();
|
335
308
|
|
336
309
|
$.ajax({
|
337
310
|
type: 'POST',
|
@@ -352,20 +325,20 @@ var GoatRPC = Class.extend({
|
|
352
325
|
}
|
353
326
|
});
|
354
327
|
|
355
|
-
var Goat = {
|
356
|
-
channelOpenFails: 0,
|
357
|
-
activeChannel: null,
|
358
|
-
pageDead: false,
|
359
|
-
components: {},
|
360
|
-
page_id: null
|
361
|
-
}
|
362
|
-
|
363
328
|
function closure(target, fn) {
|
364
329
|
return function() {
|
365
330
|
return fn.apply(target, arguments);
|
366
331
|
}
|
367
332
|
}
|
368
333
|
|
334
|
+
$.extend(Goat, {
|
335
|
+
channelOpenFails: 0,
|
336
|
+
activeChannel: null,
|
337
|
+
pageDead: false,
|
338
|
+
components: {},
|
339
|
+
page_id: null
|
340
|
+
});
|
341
|
+
|
369
342
|
$.extend(Goat, {
|
370
343
|
closure: function(fn) { return closure(this, fn); },
|
371
344
|
|
@@ -394,7 +367,7 @@ $.extend(Goat, {
|
|
394
367
|
|
395
368
|
var t = m['type'];
|
396
369
|
if(t == 'component_updated') {
|
397
|
-
|
370
|
+
Goat.RT.updateReceived(m);
|
398
371
|
} else if(t == 'redirect') {
|
399
372
|
console.log("Redirecting to " + m['location']);
|
400
373
|
sleep(2);
|
@@ -403,7 +376,7 @@ $.extend(Goat, {
|
|
403
376
|
alert("Due to inactivity, you'll need to refresh this page.");
|
404
377
|
Goat.setPageDead();
|
405
378
|
} else if(t == 'txn_complete') {
|
406
|
-
|
379
|
+
Goat.RT.txnCompleteMsg(m);
|
407
380
|
} else if(t == 'alert') {
|
408
381
|
this.showAlert(m);
|
409
382
|
} else {
|
@@ -468,7 +441,7 @@ $.extend(Goat, {
|
|
468
441
|
});
|
469
442
|
|
470
443
|
var base = Goat.channelURL();
|
471
|
-
var src = base + '?_id=' + Goat.page_id + '&jsonp=' + jsonp + '&version=' +
|
444
|
+
var src = base + '?_id=' + Goat.page_id + '&jsonp=' + jsonp + '&version=' + Goat.RT.version;
|
472
445
|
|
473
446
|
scriptTag.addEventListener('load', function() { cleanup(); Goat.reopenChannel(); }, false);
|
474
447
|
scriptTag.addEventListener('error', function() { cleanup(); logError(); Goat.reopenChannel(); }, false);
|
@@ -514,3 +487,9 @@ $.extend(Goat, {
|
|
514
487
|
});
|
515
488
|
}
|
516
489
|
});
|
490
|
+
|
491
|
+
$(document).ready(function() {
|
492
|
+
Goat.loadComponents();
|
493
|
+
setTimeout(function() { if(Goat.page_id) Goat.openChannel(); }, 1000);
|
494
|
+
});
|
495
|
+
|
data/lib/goat/js/component.js
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 12
|
10
|
+
version: 0.3.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Patrick Collison
|