goat 0.3.10 → 0.3.11

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 (3) hide show
  1. data/goat.gemspec +1 -1
  2. data/lib/goat/goat.js +38 -13
  3. metadata +3 -3
data/goat.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'goat'
3
- s.version = '0.3.10'
3
+ s.version = '0.3.11'
4
4
  s.summary = 'Pre-release beta version of Goat'
5
5
  s.author = 'Patrick Collison'
6
6
  s.email = 'patrick@collison.ie'
data/lib/goat/goat.js CHANGED
@@ -170,14 +170,6 @@ var GoatRT = {
170
170
  }
171
171
  }
172
172
 
173
- function showSpinner() {
174
- $("#menu").prepend(GoatRT.spinner);
175
- }
176
-
177
- function hideSpinner() {
178
- $("#spinner").remove();
179
- }
180
-
181
173
  function newTxn() {
182
174
  var op = new RTTxn();
183
175
  rt.ops[op.code] = op;
@@ -199,9 +191,10 @@ var GoatRT = {
199
191
  delete rt.pendingTxns[txn];
200
192
 
201
193
  if(pendingCount() == 0) {
202
- if(!txn.start) hideSpinner();
203
- if(txn.complete) txn.complete();
194
+ LoadingIndicator.hide();
204
195
  }
196
+
197
+ if(txn.complete) txn.complete();
205
198
  } else {
206
199
  console.error("Can't complete txn " + txn + ": no such txn was started");
207
200
  }
@@ -218,12 +211,44 @@ var GoatRT = {
218
211
  rt.newTxn = newTxn;
219
212
  rt.beginTxn = beginTxn;
220
213
  rt.txnCompleteMsg = txnCompleteMsg;
221
- rt.spinner = $("<img id=\"spinner\" src=\"/static/img/spinner.gif\">");
222
- rt.showSpinner = showSpinner;
223
214
 
224
215
  return rt;
225
216
  })(GoatRT);
226
217
 
218
+ var LoadingIndicator = {
219
+ url: null,
220
+ indicator: null,
221
+ where: null,
222
+ indicatorActive: false
223
+ };
224
+
225
+ (function(ld) {
226
+ function initIndicator() {
227
+ if(!ld.url || !ld.where) console.error("Loading indicator not configured");
228
+ ld.indicator = $("<img id=\"loading_indicator\" src=\"" + ld.url + "\">");
229
+ }
230
+
231
+ function show() {
232
+ ld.indicatorActive = true;
233
+ $(ld.where).prepend(ld.indicator);
234
+ }
235
+
236
+ function hide() {
237
+ if(ld.indicatorActive)
238
+ ld.indicator.remove();
239
+ }
240
+
241
+ $(document).ready(function() {
242
+ initIndicator();
243
+ new Image(ld.url);
244
+ });
245
+
246
+ ld.show = show;
247
+ ld.hide = hide;
248
+
249
+ return ld;
250
+ })(LoadingIndicator);
251
+
227
252
  var RTTxn = Class.extend({
228
253
  init: function() {
229
254
  this.code = String.random(8, 'txn');
@@ -306,7 +331,7 @@ var GoatRPC = Class.extend({
306
331
  }
307
332
 
308
333
  if(this.start) this.start()
309
- else if(this.rt) GoatRT.showSpinner();
334
+ else if(this.rt) LoadingIndicator.show();
310
335
 
311
336
  $.ajax({
312
337
  type: 'POST',
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: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 10
10
- version: 0.3.10
9
+ - 11
10
+ version: 0.3.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrick Collison