bivouac 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/README +6 -7
  2. data/bin/bivouac +1 -1
  3. data/doc/rdoc/classes/BivouacHelpers/BaseView.html +178 -0
  4. data/doc/rdoc/classes/BivouacHelpers/FormView.html +398 -0
  5. data/doc/rdoc/classes/BivouacHelpers/HtmlView.html +305 -0
  6. data/doc/rdoc/classes/BivouacHelpers/JavaScriptView.html +573 -0
  7. data/doc/rdoc/classes/BivouacHelpers/ScriptAculoUsView.html +258 -0
  8. data/doc/rdoc/classes/BivouacHelpers/TooltipView.html +158 -0
  9. data/doc/rdoc/classes/BivouacHelpers.html +117 -0
  10. data/doc/rdoc/classes/JavaScriptGenerator.html +564 -0
  11. data/doc/rdoc/created.rid +1 -0
  12. data/doc/rdoc/files/AUTHORS.html +109 -0
  13. data/doc/rdoc/files/COPYING.html +533 -0
  14. data/doc/rdoc/files/README.html +427 -0
  15. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/base_rb.html +109 -0
  16. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/form_rb.html +109 -0
  17. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/html_rb.html +109 -0
  18. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/javascript_rb.html +113 -0
  19. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/scriptaculous_rb.html +113 -0
  20. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/tooltip_rb.html +109 -0
  21. data/doc/rdoc/index.html +10 -0
  22. data/doc/rdoc/permalink.gif +0 -0
  23. data/doc/rdoc/rdoc-style.css +106 -0
  24. data/doc/rdoc/rubyfr.png +0 -0
  25. data/examples/bivouac_sample/Rakefile +48 -0
  26. data/examples/bivouac_sample/app/bivouac_sample.rb +15 -7
  27. data/examples/bivouac_sample/app/controllers/index.rb +2 -2
  28. data/examples/bivouac_sample/app/controllers/sound.rb +10 -0
  29. data/examples/bivouac_sample/app/helpers/_helpers.rb +6 -3
  30. data/examples/bivouac_sample/app/views/sound.rb +16 -0
  31. data/examples/bivouac_sample/config/environment.rb +5 -2
  32. data/examples/bivouac_sample/config/postamble.rb +89 -18
  33. data/examples/bivouac_sample/public/javascripts/builder.js +12 -7
  34. data/examples/bivouac_sample/public/javascripts/controls.js +485 -355
  35. data/examples/bivouac_sample/public/javascripts/dragdrop.js +82 -52
  36. data/examples/bivouac_sample/public/javascripts/effects.js +361 -329
  37. data/examples/bivouac_sample/public/javascripts/prototype.js +2826 -1120
  38. data/examples/bivouac_sample/public/javascripts/scriptaculous.js +15 -8
  39. data/examples/bivouac_sample/public/javascripts/slider.js +40 -43
  40. data/examples/bivouac_sample/public/javascripts/sound.js +55 -0
  41. data/examples/bivouac_sample/public/javascripts/unittest.js +16 -12
  42. data/examples/bivouac_sample/public/sound/sword.mp3 +0 -0
  43. data/examples/bivouac_sample/script/console +6 -0
  44. data/examples/bivouac_sample/script/plugin +3 -0
  45. data/examples/bivouac_sample/script/server +2 -1
  46. data/examples/bivouac_sample/test/test_sound.rb +15 -0
  47. data/lib/bivouac/helpers/view/goh/sound.rb +38 -0
  48. data/lib/bivouac/template/application/helpers_goh.rb +2 -0
  49. data/lib/bivouac/template/static/builder.js +12 -7
  50. data/lib/bivouac/template/static/controls.js +485 -355
  51. data/lib/bivouac/template/static/dragdrop.js +82 -52
  52. data/lib/bivouac/template/static/effects.js +361 -329
  53. data/lib/bivouac/template/static/prototype.js +2826 -1120
  54. data/lib/bivouac/template/static/scriptaculous.js +15 -8
  55. data/lib/bivouac/template/static/slider.js +40 -43
  56. data/lib/bivouac/template/static/sound.js +55 -0
  57. data/lib/bivouac/template/static/unittest.js +16 -12
  58. metadata +45 -2
@@ -1,6 +1,6 @@
1
- // script.aculo.us scriptaculous.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
1
+ // script.aculo.us scriptaculous.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
2
2
 
3
- // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
3
+ // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4
4
  //
5
5
  // Permission is hereby granted, free of charge, to any person obtaining
6
6
  // a copy of this software and associated documentation files (the
@@ -24,25 +24,32 @@
24
24
  // For details, see the script.aculo.us web site: http://script.aculo.us/
25
25
 
26
26
  var Scriptaculous = {
27
- Version: '1.7.0',
27
+ Version: '1.8.1',
28
28
  require: function(libraryName) {
29
29
  // inserting via DOM fails in Safari 2.0, so brute force approach
30
- document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
30
+ document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
31
31
  },
32
+ REQUIRED_PROTOTYPE: '1.6.0',
32
33
  load: function() {
34
+ function convertVersionString(versionString){
35
+ var r = versionString.split('.');
36
+ return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]);
37
+ }
38
+
33
39
  if((typeof Prototype=='undefined') ||
34
40
  (typeof Element == 'undefined') ||
35
41
  (typeof Element.Methods=='undefined') ||
36
- parseFloat(Prototype.Version.split(".")[0] + "." +
37
- Prototype.Version.split(".")[1]) < 1.5)
38
- throw("script.aculo.us requires the Prototype JavaScript framework >= 1.5.0");
42
+ (convertVersionString(Prototype.Version) <
43
+ convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
44
+ throw("script.aculo.us requires the Prototype JavaScript framework >= " +
45
+ Scriptaculous.REQUIRED_PROTOTYPE);
39
46
 
40
47
  $A(document.getElementsByTagName("script")).findAll( function(s) {
41
48
  return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
42
49
  }).each( function(s) {
43
50
  var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
44
51
  var includes = s.src.match(/\?.*load=([a-z,]*)/);
45
- (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider').split(',').each(
52
+ (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
46
53
  function(include) { Scriptaculous.require(path+include+'.js') });
47
54
  });
48
55
  }
@@ -1,12 +1,11 @@
1
- // script.aculo.us slider.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
1
+ // script.aculo.us slider.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
2
2
 
3
- // Copyright (c) 2005, 2006 Marty Haught, Thomas Fuchs
3
+ // Copyright (c) 2005-2007 Marty Haught, Thomas Fuchs
4
4
  //
5
5
  // script.aculo.us is freely distributable under the terms of an MIT-style license.
6
6
  // For details, see the script.aculo.us web site: http://script.aculo.us/
7
7
 
8
- if(!Control) var Control = {};
9
- Control.Slider = Class.create();
8
+ if (!Control) var Control = { };
10
9
 
11
10
  // options:
12
11
  // axis: 'vertical', or 'horizontal' (default)
@@ -14,18 +13,18 @@ Control.Slider = Class.create();
14
13
  // callbacks:
15
14
  // onChange(value)
16
15
  // onSlide(value)
17
- Control.Slider.prototype = {
16
+ Control.Slider = Class.create({
18
17
  initialize: function(handle, track, options) {
19
18
  var slider = this;
20
19
 
21
- if(handle instanceof Array) {
20
+ if (Object.isArray(handle)) {
22
21
  this.handles = handle.collect( function(e) { return $(e) });
23
22
  } else {
24
23
  this.handles = [$(handle)];
25
24
  }
26
25
 
27
26
  this.track = $(track);
28
- this.options = options || {};
27
+ this.options = options || { };
29
28
 
30
29
  this.axis = this.options.axis || 'horizontal';
31
30
  this.increment = this.options.increment || 1;
@@ -59,11 +58,11 @@ Control.Slider.prototype = {
59
58
  this.dragging = false;
60
59
  this.disabled = false;
61
60
 
62
- if(this.options.disabled) this.setDisabled();
61
+ if (this.options.disabled) this.setDisabled();
63
62
 
64
63
  // Allowed values array
65
64
  this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
66
- if(this.allowedValues) {
65
+ if (this.allowedValues) {
67
66
  this.minimum = this.allowedValues.min();
68
67
  this.maximum = this.allowedValues.max();
69
68
  }
@@ -76,16 +75,15 @@ Control.Slider.prototype = {
76
75
  this.handles.each( function(h,i) {
77
76
  i = slider.handles.length-1-i;
78
77
  slider.setValue(parseFloat(
79
- (slider.options.sliderValue instanceof Array ?
78
+ (Object.isArray(slider.options.sliderValue) ?
80
79
  slider.options.sliderValue[i] : slider.options.sliderValue) ||
81
80
  slider.range.start), i);
82
- Element.makePositioned(h); // fix IE
83
- Event.observe(h, "mousedown", slider.eventMouseDown);
81
+ h.makePositioned().observe("mousedown", slider.eventMouseDown);
84
82
  });
85
83
 
86
- Event.observe(this.track, "mousedown", this.eventMouseDown);
87
- Event.observe(document, "mouseup", this.eventMouseUp);
88
- Event.observe(document, "mousemove", this.eventMouseMove);
84
+ this.track.observe("mousedown", this.eventMouseDown);
85
+ document.observe("mouseup", this.eventMouseUp);
86
+ document.observe("mousemove", this.eventMouseMove);
89
87
 
90
88
  this.initialized = true;
91
89
  },
@@ -105,36 +103,36 @@ Control.Slider.prototype = {
105
103
  this.disabled = false;
106
104
  },
107
105
  getNearestValue: function(value){
108
- if(this.allowedValues){
109
- if(value >= this.allowedValues.max()) return(this.allowedValues.max());
110
- if(value <= this.allowedValues.min()) return(this.allowedValues.min());
106
+ if (this.allowedValues){
107
+ if (value >= this.allowedValues.max()) return(this.allowedValues.max());
108
+ if (value <= this.allowedValues.min()) return(this.allowedValues.min());
111
109
 
112
110
  var offset = Math.abs(this.allowedValues[0] - value);
113
111
  var newValue = this.allowedValues[0];
114
112
  this.allowedValues.each( function(v) {
115
113
  var currentOffset = Math.abs(v - value);
116
- if(currentOffset <= offset){
114
+ if (currentOffset <= offset){
117
115
  newValue = v;
118
116
  offset = currentOffset;
119
117
  }
120
118
  });
121
119
  return newValue;
122
120
  }
123
- if(value > this.range.end) return this.range.end;
124
- if(value < this.range.start) return this.range.start;
121
+ if (value > this.range.end) return this.range.end;
122
+ if (value < this.range.start) return this.range.start;
125
123
  return value;
126
124
  },
127
125
  setValue: function(sliderValue, handleIdx){
128
- if(!this.active) {
126
+ if (!this.active) {
129
127
  this.activeHandleIdx = handleIdx || 0;
130
128
  this.activeHandle = this.handles[this.activeHandleIdx];
131
129
  this.updateStyles();
132
130
  }
133
131
  handleIdx = handleIdx || this.activeHandleIdx || 0;
134
- if(this.initialized && this.restricted) {
135
- if((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
132
+ if (this.initialized && this.restricted) {
133
+ if ((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
136
134
  sliderValue = this.values[handleIdx-1];
137
- if((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
135
+ if ((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
138
136
  sliderValue = this.values[handleIdx+1];
139
137
  }
140
138
  sliderValue = this.getNearestValue(sliderValue);
@@ -145,7 +143,7 @@ Control.Slider.prototype = {
145
143
  this.translateToPx(sliderValue);
146
144
 
147
145
  this.drawSpans();
148
- if(!this.dragging || !this.event) this.updateFinished();
146
+ if (!this.dragging || !this.event) this.updateFinished();
149
147
  },
150
148
  setValueBy: function(delta, handleIdx) {
151
149
  this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
@@ -173,24 +171,24 @@ Control.Slider.prototype = {
173
171
  (this.track.offsetHeight != 0 ? this.track.offsetHeight :
174
172
  this.track.style.height.replace(/px$/,"")) - this.alignY :
175
173
  (this.track.offsetWidth != 0 ? this.track.offsetWidth :
176
- this.track.style.width.replace(/px$/,"")) - this.alignY);
174
+ this.track.style.width.replace(/px$/,"")) - this.alignX);
177
175
  },
178
176
  isVertical: function(){
179
177
  return (this.axis == 'vertical');
180
178
  },
181
179
  drawSpans: function() {
182
180
  var slider = this;
183
- if(this.spans)
181
+ if (this.spans)
184
182
  $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
185
- if(this.options.startSpan)
183
+ if (this.options.startSpan)
186
184
  this.setSpan(this.options.startSpan,
187
185
  $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
188
- if(this.options.endSpan)
186
+ if (this.options.endSpan)
189
187
  this.setSpan(this.options.endSpan,
190
188
  $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
191
189
  },
192
190
  setSpan: function(span, range) {
193
- if(this.isVertical()) {
191
+ if (this.isVertical()) {
194
192
  span.style.top = this.translateToPx(range.start);
195
193
  span.style.height = this.translateToPx(range.end - range.start + this.range.start);
196
194
  } else {
@@ -203,14 +201,14 @@ Control.Slider.prototype = {
203
201
  Element.addClassName(this.activeHandle, 'selected');
204
202
  },
205
203
  startDrag: function(event) {
206
- if(Event.isLeftClick(event)) {
207
- if(!this.disabled){
204
+ if (Event.isLeftClick(event)) {
205
+ if (!this.disabled){
208
206
  this.active = true;
209
207
 
210
208
  var handle = Event.element(event);
211
209
  var pointer = [Event.pointerX(event), Event.pointerY(event)];
212
210
  var track = handle;
213
- if(track==this.track) {
211
+ if (track==this.track) {
214
212
  var offsets = Position.cumulativeOffset(this.track);
215
213
  this.event = event;
216
214
  this.setValue(this.translateToValue(
@@ -224,7 +222,7 @@ Control.Slider.prototype = {
224
222
  while((this.handles.indexOf(handle) == -1) && handle.parentNode)
225
223
  handle = handle.parentNode;
226
224
 
227
- if(this.handles.indexOf(handle)!=-1) {
225
+ if (this.handles.indexOf(handle)!=-1) {
228
226
  this.activeHandle = handle;
229
227
  this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
230
228
  this.updateStyles();
@@ -239,11 +237,10 @@ Control.Slider.prototype = {
239
237
  }
240
238
  },
241
239
  update: function(event) {
242
- if(this.active) {
243
- if(!this.dragging) this.dragging = true;
240
+ if (this.active) {
241
+ if (!this.dragging) this.dragging = true;
244
242
  this.draw(event);
245
- // fix AppleWebKit rendering
246
- if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
243
+ if (Prototype.Browser.WebKit) window.scrollBy(0,0);
247
244
  Event.stop(event);
248
245
  }
249
246
  },
@@ -254,11 +251,11 @@ Control.Slider.prototype = {
254
251
  pointer[1] -= this.offsetY + offsets[1];
255
252
  this.event = event;
256
253
  this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
257
- if(this.initialized && this.options.onSlide)
254
+ if (this.initialized && this.options.onSlide)
258
255
  this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
259
256
  },
260
257
  endDrag: function(event) {
261
- if(this.active && this.dragging) {
258
+ if (this.active && this.dragging) {
262
259
  this.finishDrag(event, true);
263
260
  Event.stop(event);
264
261
  }
@@ -271,8 +268,8 @@ Control.Slider.prototype = {
271
268
  this.updateFinished();
272
269
  },
273
270
  updateFinished: function() {
274
- if(this.initialized && this.options.onChange)
271
+ if (this.initialized && this.options.onChange)
275
272
  this.options.onChange(this.values.length>1 ? this.values : this.value, this);
276
273
  this.event = null;
277
274
  }
278
- }
275
+ });
@@ -0,0 +1,55 @@
1
+ // script.aculo.us sound.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
2
+
3
+ // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4
+ //
5
+ // Based on code created by Jules Gravinese (http://www.webveteran.com/)
6
+ //
7
+ // script.aculo.us is freely distributable under the terms of an MIT-style license.
8
+ // For details, see the script.aculo.us web site: http://script.aculo.us/
9
+
10
+ Sound = {
11
+ tracks: {},
12
+ _enabled: true,
13
+ template:
14
+ new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'),
15
+ enable: function(){
16
+ Sound._enabled = true;
17
+ },
18
+ disable: function(){
19
+ Sound._enabled = false;
20
+ },
21
+ play: function(url){
22
+ if(!Sound._enabled) return;
23
+ var options = Object.extend({
24
+ track: 'global', url: url, replace: false
25
+ }, arguments[1] || {});
26
+
27
+ if(options.replace && this.tracks[options.track]) {
28
+ $R(0, this.tracks[options.track].id).each(function(id){
29
+ var sound = $('sound_'+options.track+'_'+id);
30
+ sound.Stop && sound.Stop();
31
+ sound.remove();
32
+ })
33
+ this.tracks[options.track] = null;
34
+ }
35
+
36
+ if(!this.tracks[options.track])
37
+ this.tracks[options.track] = { id: 0 }
38
+ else
39
+ this.tracks[options.track].id++;
40
+
41
+ options.id = this.tracks[options.track].id;
42
+ $$('body')[0].insert(
43
+ Prototype.Browser.IE ? new Element('bgsound',{
44
+ id: 'sound_'+options.track+'_'+options.id,
45
+ src: options.url, loop: 1, autostart: true
46
+ }) : Sound.template.evaluate(options));
47
+ }
48
+ };
49
+
50
+ if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
51
+ if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
52
+ Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>')
53
+ else
54
+ Sound.play = function(){}
55
+ }
@@ -1,8 +1,8 @@
1
- // script.aculo.us unittest.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
1
+ // script.aculo.us unittest.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
2
2
 
3
- // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4
- // (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com)
5
- // (c) 2005, 2006 Michael Schuerig (http://www.schuerig.de/michael/)
3
+ // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4
+ // (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
5
+ // (c) 2005-2007 Michael Schuerig (http://www.schuerig.de/michael/)
6
6
  //
7
7
  // script.aculo.us is freely distributable under the terms of an MIT-style license.
8
8
  // For details, see the script.aculo.us web site: http://script.aculo.us/
@@ -524,15 +524,19 @@ Test.setupBDDExtensionMethods = function(){
524
524
  shouldNotBe: 'assertReturnsFalse',
525
525
  shouldRespondTo: 'assertRespondsTo'
526
526
  };
527
- Test.BDDMethods = {};
528
- for(m in METHODMAP) {
529
- Test.BDDMethods[m] = eval(
530
- 'function(){'+
531
- 'var args = $A(arguments);'+
532
- 'var scope = args.shift();'+
533
- 'scope.'+METHODMAP[m]+'.apply(scope,(args || []).concat([this])); }');
527
+ var makeAssertion = function(assertion, args, object) {
528
+ this[assertion].apply(this,(args || []).concat([object]));
534
529
  }
535
- [Array.prototype, String.prototype, Number.prototype].each(
530
+
531
+ Test.BDDMethods = {};
532
+ $H(METHODMAP).each(function(pair) {
533
+ Test.BDDMethods[pair.key] = function() {
534
+ var args = $A(arguments);
535
+ var scope = args.shift();
536
+ makeAssertion.apply(scope, [pair.value, args, this]); };
537
+ });
538
+
539
+ [Array.prototype, String.prototype, Number.prototype, Boolean.prototype].each(
536
540
  function(p){ Object.extend(p, Test.BDDMethods) }
537
541
  );
538
542
  }
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ app = File.dirname(__FILE__) + "/../app/bivouac_sample.rb"
4
+
5
+ ENV['BIVOUAC_ROOT'] = File.expand_path( File.dirname(__FILE__) + "/../" )
6
+ system "ruby #{app} -c #{ARGV.join(' ')}"
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'bivouac/commands/plugin'
@@ -2,4 +2,5 @@
2
2
  require 'rubygems'
3
3
  app = File.dirname(__FILE__) + "/../app/bivouac_sample.rb"
4
4
 
5
- system "ruby #{app} #{ARGV.join(' ')}"
5
+ ENV['BIVOUAC_ROOT'] = File.expand_path( File.dirname(__FILE__) + "/../" )
6
+ system "ruby #{app} #{ARGV.join(' ')} --"
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'mosquito'
3
+
4
+ ENV['BIVOUAC_ROOT'] = File.expand_path( File.dirname(__FILE__) + "/../" )
5
+ require ENV['BIVOUAC_ROOT'] + "/app/bivouac_sample"
6
+
7
+ BivouacSample.create if BivouacSample.respond_to? :create
8
+ include BivouacSample::Models
9
+
10
+ class TestBivouacSample < Camping::FunctionalTest
11
+ def test_sound
12
+ get '/sound'
13
+ assert_response :success
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ module BivouacHelpers
2
+ module SoundView
3
+ # Play the file +file+
4
+ #
5
+ # Example:
6
+ # play_sound("my_song.mp3", :replace => true)
7
+ #
8
+ # The +file+ must be in +public+
9
+ #
10
+ # You can change the behaviour with various options, see
11
+ # http://script.aculo.us for more documentation.
12
+ def play_sound( file, options = {} )
13
+ javascript_tag(play_sound_js(file, options) + ";\n")
14
+ end
15
+
16
+ def play_sound_js( file, options = {} ) #:nodoc:
17
+ %(Sound.play('/public/#{file}', #{options_for_javascript(options)}); return false)
18
+ end
19
+
20
+ # Disable sound
21
+ def disable_sound( )
22
+ javascript_tag(disable_sound_js + ";\n")
23
+ end
24
+
25
+ def disable_sound_js( ) #:nodoc:
26
+ %(Sound.disable(); return false)
27
+ end
28
+
29
+ # Enable sound
30
+ def enable_sound( )
31
+ javascript_tag(enable_sound_js + ";\n")
32
+ end
33
+
34
+ def enable_sound_js( ) #:nodoc:
35
+ %(Sound.enable(); return false)
36
+ end
37
+ end
38
+ end
@@ -12,6 +12,7 @@ require 'bivouac/helpers/view/goh/html'
12
12
  require 'bivouac/helpers/view/goh/form'
13
13
  require 'bivouac/helpers/view/goh/scriptaculous'
14
14
  require 'bivouac/helpers/view/goh/javascript'
15
+ require 'bivouac/helpers/view/goh/sound'
15
16
  require 'bivouac/helpers/view/goh/tooltip'
16
17
 
17
18
  helpers = [
@@ -20,6 +21,7 @@ helpers = [
20
21
  BivouacHelpers::FormView,
21
22
  BivouacHelpers::ScriptAculoUsView,
22
23
  BivouacHelpers::JavaScriptView,
24
+ BivouacHelpers::SoundView,
23
25
  BivouacHelpers::TooltipView
24
26
  ] + viewHelperModule
25
27
 
@@ -1,6 +1,6 @@
1
- // script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
1
+ // script.aculo.us builder.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
2
2
 
3
- // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
3
+ // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4
4
  //
5
5
  // script.aculo.us is freely distributable under the terms of an MIT-style license.
6
6
  // For details, see the script.aculo.us web site: http://script.aculo.us/
@@ -48,7 +48,8 @@ var Builder = {
48
48
  // attributes (or text)
49
49
  if(arguments[1])
50
50
  if(this._isStringOrNumber(arguments[1]) ||
51
- (arguments[1] instanceof Array)) {
51
+ (arguments[1] instanceof Array) ||
52
+ arguments[1].tagName) {
52
53
  this._children(element, arguments[1]);
53
54
  } else {
54
55
  var attrs = this._attributes(arguments[1]);
@@ -66,7 +67,7 @@ var Builder = {
66
67
  }
67
68
  if(element.tagName.toUpperCase() != elementName)
68
69
  element = parentElement.getElementsByTagName(elementName)[0];
69
- }
70
+ }
70
71
  }
71
72
 
72
73
  // text, or array of children
@@ -88,10 +89,14 @@ var Builder = {
88
89
  var attrs = [];
89
90
  for(attribute in attributes)
90
91
  attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
91
- '="' + attributes[attribute].toString().escapeHTML() + '"');
92
+ '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"');
92
93
  return attrs.join(" ");
93
94
  },
94
95
  _children: function(element, children) {
96
+ if(children.tagName) {
97
+ element.appendChild(children);
98
+ return;
99
+ }
95
100
  if(typeof children=='object') { // array can hold nodes and text
96
101
  children.flatten().each( function(e) {
97
102
  if(typeof e=='object')
@@ -101,8 +106,8 @@ var Builder = {
101
106
  element.appendChild(Builder._text(e));
102
107
  });
103
108
  } else
104
- if(Builder._isStringOrNumber(children))
105
- element.appendChild(Builder._text(children));
109
+ if(Builder._isStringOrNumber(children))
110
+ element.appendChild(Builder._text(children));
106
111
  },
107
112
  _isStringOrNumber: function(param) {
108
113
  return(typeof param=='string' || typeof param=='number');