ajaxlibs 0.1.0
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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +97 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/lib/ajaxlibs/constants.rb +3 -0
- data/lib/ajaxlibs/exceptions.rb +8 -0
- data/lib/ajaxlibs/includes_helper.rb +90 -0
- data/lib/ajaxlibs/libraries/jquery.rb +10 -0
- data/lib/ajaxlibs/libraries/jqueryui.rb +16 -0
- data/lib/ajaxlibs/libraries/prototype.rb +5 -0
- data/lib/ajaxlibs/libraries/scriptaculous.rb +9 -0
- data/lib/ajaxlibs/library.rb +73 -0
- data/lib/ajaxlibs/versions_tools.rb +16 -0
- data/lib/ajaxlibs.rb +34 -0
- data/public/jquery/1.2.3/jquery.js +3408 -0
- data/public/jquery/1.2.6/jquery.js +3549 -0
- data/public/jquery/1.3.0/jquery.js +4241 -0
- data/public/jquery/1.3.1/jquery.js +4241 -0
- data/public/jquery/1.3.2/jquery.js +4376 -0
- data/public/jquery/1.4.0/jquery.js +5999 -0
- data/public/jquery/1.4.1/jquery.js +6078 -0
- data/public/jquery/1.4.2/jquery.js +6240 -0
- data/public/jqueryui/1.5.2/jquery-ui.js +7598 -0
- data/public/jqueryui/1.5.3/jquery-ui.js +7616 -0
- data/public/jqueryui/1.6/jquery-ui.js +8862 -0
- data/public/jqueryui/1.7.0/jquery-ui.js +9049 -0
- data/public/jqueryui/1.7.1/jquery-ui.js +9074 -0
- data/public/jqueryui/1.7.2/jquery-ui.js +9133 -0
- data/public/mootools/1.1.1/mootools.js +7102 -0
- data/public/mootools/1.1.2/mootools.js +7102 -0
- data/public/mootools/1.2.1/mootools.js +3946 -0
- data/public/mootools/1.2.2/mootools.js +4003 -0
- data/public/mootools/1.2.3/mootools.js +4036 -0
- data/public/mootools/1.2.4/mootools.js +4329 -0
- data/public/prototype/1.6.0.2/prototype.js +4221 -0
- data/public/prototype/1.6.0.3/prototype.js +4320 -0
- data/public/prototype/1.6.1.0/prototype.js +4874 -0
- data/public/scriptaculous/1.8.1/builder.js +136 -0
- data/public/scriptaculous/1.8.1/controls.js +965 -0
- data/public/scriptaculous/1.8.1/dragdrop.js +974 -0
- data/public/scriptaculous/1.8.1/effects.js +1122 -0
- data/public/scriptaculous/1.8.1/scriptaculous.js +58 -0
- data/public/scriptaculous/1.8.1/slider.js +275 -0
- data/public/scriptaculous/1.8.1/sound.js +55 -0
- data/public/scriptaculous/1.8.2/builder.js +136 -0
- data/public/scriptaculous/1.8.2/controls.js +965 -0
- data/public/scriptaculous/1.8.2/dragdrop.js +975 -0
- data/public/scriptaculous/1.8.2/effects.js +1130 -0
- data/public/scriptaculous/1.8.2/scriptaculous.js +60 -0
- data/public/scriptaculous/1.8.2/slider.js +275 -0
- data/public/scriptaculous/1.8.2/sound.js +55 -0
- data/public/scriptaculous/1.8.3/builder.js +136 -0
- data/public/scriptaculous/1.8.3/controls.js +965 -0
- data/public/scriptaculous/1.8.3/dragdrop.js +974 -0
- data/public/scriptaculous/1.8.3/effects.js +1123 -0
- data/public/scriptaculous/1.8.3/scriptaculous.js +68 -0
- data/public/scriptaculous/1.8.3/slider.js +275 -0
- data/public/scriptaculous/1.8.3/sound.js +59 -0
- data/spec/includes_helper_spec.rb +139 -0
- data/spec/library_spec.rb +84 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/versions_tools_spec.rb +27 -0
- metadata +143 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
// script.aculo.us scriptaculous.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
|
2
|
+
|
3
|
+
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
4
|
+
//
|
5
|
+
// Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
// a copy of this software and associated documentation files (the
|
7
|
+
// "Software"), to deal in the Software without restriction, including
|
8
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
// permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
// the following conditions:
|
12
|
+
//
|
13
|
+
// The above copyright notice and this permission notice shall be
|
14
|
+
// included in all copies or substantial portions of the Software.
|
15
|
+
//
|
16
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
//
|
24
|
+
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
25
|
+
|
26
|
+
var Scriptaculous = {
|
27
|
+
Version: '1.8.3',
|
28
|
+
require: function(libraryName) {
|
29
|
+
try{
|
30
|
+
// inserting via DOM fails in Safari 2.0, so brute force approach
|
31
|
+
document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
|
32
|
+
} catch(e) {
|
33
|
+
// for xhtml+xml served content, fall back to DOM methods
|
34
|
+
var script = document.createElement('script');
|
35
|
+
script.type = 'text/javascript';
|
36
|
+
script.src = libraryName;
|
37
|
+
document.getElementsByTagName('head')[0].appendChild(script);
|
38
|
+
}
|
39
|
+
},
|
40
|
+
REQUIRED_PROTOTYPE: '1.6.0.3',
|
41
|
+
load: function() {
|
42
|
+
function convertVersionString(versionString) {
|
43
|
+
var v = versionString.replace(/_.*|\./g, '');
|
44
|
+
v = parseInt(v + '0'.times(4-v.length));
|
45
|
+
return versionString.indexOf('_') > -1 ? v-1 : v;
|
46
|
+
}
|
47
|
+
|
48
|
+
if((typeof Prototype=='undefined') ||
|
49
|
+
(typeof Element == 'undefined') ||
|
50
|
+
(typeof Element.Methods=='undefined') ||
|
51
|
+
(convertVersionString(Prototype.Version) <
|
52
|
+
convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
|
53
|
+
throw("script.aculo.us requires the Prototype JavaScript framework >= " +
|
54
|
+
Scriptaculous.REQUIRED_PROTOTYPE);
|
55
|
+
|
56
|
+
var js = /scriptaculous\.js(\?.*)?$/;
|
57
|
+
$$('head script[src]').findAll(function(s) {
|
58
|
+
return s.src.match(js);
|
59
|
+
}).each(function(s) {
|
60
|
+
var path = s.src.replace(js, ''),
|
61
|
+
includes = s.src.match(/\?.*load=([a-z,]*)/);
|
62
|
+
(includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
|
63
|
+
function(include) { Scriptaculous.require(path+include+'.js') });
|
64
|
+
});
|
65
|
+
}
|
66
|
+
};
|
67
|
+
|
68
|
+
Scriptaculous.load();
|
@@ -0,0 +1,275 @@
|
|
1
|
+
// script.aculo.us slider.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
|
2
|
+
|
3
|
+
// Copyright (c) 2005-2009 Marty Haught, Thomas Fuchs
|
4
|
+
//
|
5
|
+
// script.aculo.us is freely distributable under the terms of an MIT-style license.
|
6
|
+
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
7
|
+
|
8
|
+
if (!Control) var Control = { };
|
9
|
+
|
10
|
+
// options:
|
11
|
+
// axis: 'vertical', or 'horizontal' (default)
|
12
|
+
//
|
13
|
+
// callbacks:
|
14
|
+
// onChange(value)
|
15
|
+
// onSlide(value)
|
16
|
+
Control.Slider = Class.create({
|
17
|
+
initialize: function(handle, track, options) {
|
18
|
+
var slider = this;
|
19
|
+
|
20
|
+
if (Object.isArray(handle)) {
|
21
|
+
this.handles = handle.collect( function(e) { return $(e) });
|
22
|
+
} else {
|
23
|
+
this.handles = [$(handle)];
|
24
|
+
}
|
25
|
+
|
26
|
+
this.track = $(track);
|
27
|
+
this.options = options || { };
|
28
|
+
|
29
|
+
this.axis = this.options.axis || 'horizontal';
|
30
|
+
this.increment = this.options.increment || 1;
|
31
|
+
this.step = parseInt(this.options.step || '1');
|
32
|
+
this.range = this.options.range || $R(0,1);
|
33
|
+
|
34
|
+
this.value = 0; // assure backwards compat
|
35
|
+
this.values = this.handles.map( function() { return 0 });
|
36
|
+
this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
|
37
|
+
this.options.startSpan = $(this.options.startSpan || null);
|
38
|
+
this.options.endSpan = $(this.options.endSpan || null);
|
39
|
+
|
40
|
+
this.restricted = this.options.restricted || false;
|
41
|
+
|
42
|
+
this.maximum = this.options.maximum || this.range.end;
|
43
|
+
this.minimum = this.options.minimum || this.range.start;
|
44
|
+
|
45
|
+
// Will be used to align the handle onto the track, if necessary
|
46
|
+
this.alignX = parseInt(this.options.alignX || '0');
|
47
|
+
this.alignY = parseInt(this.options.alignY || '0');
|
48
|
+
|
49
|
+
this.trackLength = this.maximumOffset() - this.minimumOffset();
|
50
|
+
|
51
|
+
this.handleLength = this.isVertical() ?
|
52
|
+
(this.handles[0].offsetHeight != 0 ?
|
53
|
+
this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :
|
54
|
+
(this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
|
55
|
+
this.handles[0].style.width.replace(/px$/,""));
|
56
|
+
|
57
|
+
this.active = false;
|
58
|
+
this.dragging = false;
|
59
|
+
this.disabled = false;
|
60
|
+
|
61
|
+
if (this.options.disabled) this.setDisabled();
|
62
|
+
|
63
|
+
// Allowed values array
|
64
|
+
this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
|
65
|
+
if (this.allowedValues) {
|
66
|
+
this.minimum = this.allowedValues.min();
|
67
|
+
this.maximum = this.allowedValues.max();
|
68
|
+
}
|
69
|
+
|
70
|
+
this.eventMouseDown = this.startDrag.bindAsEventListener(this);
|
71
|
+
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
|
72
|
+
this.eventMouseMove = this.update.bindAsEventListener(this);
|
73
|
+
|
74
|
+
// Initialize handles in reverse (make sure first handle is active)
|
75
|
+
this.handles.each( function(h,i) {
|
76
|
+
i = slider.handles.length-1-i;
|
77
|
+
slider.setValue(parseFloat(
|
78
|
+
(Object.isArray(slider.options.sliderValue) ?
|
79
|
+
slider.options.sliderValue[i] : slider.options.sliderValue) ||
|
80
|
+
slider.range.start), i);
|
81
|
+
h.makePositioned().observe("mousedown", slider.eventMouseDown);
|
82
|
+
});
|
83
|
+
|
84
|
+
this.track.observe("mousedown", this.eventMouseDown);
|
85
|
+
document.observe("mouseup", this.eventMouseUp);
|
86
|
+
document.observe("mousemove", this.eventMouseMove);
|
87
|
+
|
88
|
+
this.initialized = true;
|
89
|
+
},
|
90
|
+
dispose: function() {
|
91
|
+
var slider = this;
|
92
|
+
Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
|
93
|
+
Event.stopObserving(document, "mouseup", this.eventMouseUp);
|
94
|
+
Event.stopObserving(document, "mousemove", this.eventMouseMove);
|
95
|
+
this.handles.each( function(h) {
|
96
|
+
Event.stopObserving(h, "mousedown", slider.eventMouseDown);
|
97
|
+
});
|
98
|
+
},
|
99
|
+
setDisabled: function(){
|
100
|
+
this.disabled = true;
|
101
|
+
},
|
102
|
+
setEnabled: function(){
|
103
|
+
this.disabled = false;
|
104
|
+
},
|
105
|
+
getNearestValue: function(value){
|
106
|
+
if (this.allowedValues){
|
107
|
+
if (value >= this.allowedValues.max()) return(this.allowedValues.max());
|
108
|
+
if (value <= this.allowedValues.min()) return(this.allowedValues.min());
|
109
|
+
|
110
|
+
var offset = Math.abs(this.allowedValues[0] - value);
|
111
|
+
var newValue = this.allowedValues[0];
|
112
|
+
this.allowedValues.each( function(v) {
|
113
|
+
var currentOffset = Math.abs(v - value);
|
114
|
+
if (currentOffset <= offset){
|
115
|
+
newValue = v;
|
116
|
+
offset = currentOffset;
|
117
|
+
}
|
118
|
+
});
|
119
|
+
return newValue;
|
120
|
+
}
|
121
|
+
if (value > this.range.end) return this.range.end;
|
122
|
+
if (value < this.range.start) return this.range.start;
|
123
|
+
return value;
|
124
|
+
},
|
125
|
+
setValue: function(sliderValue, handleIdx){
|
126
|
+
if (!this.active) {
|
127
|
+
this.activeHandleIdx = handleIdx || 0;
|
128
|
+
this.activeHandle = this.handles[this.activeHandleIdx];
|
129
|
+
this.updateStyles();
|
130
|
+
}
|
131
|
+
handleIdx = handleIdx || this.activeHandleIdx || 0;
|
132
|
+
if (this.initialized && this.restricted) {
|
133
|
+
if ((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
|
134
|
+
sliderValue = this.values[handleIdx-1];
|
135
|
+
if ((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
|
136
|
+
sliderValue = this.values[handleIdx+1];
|
137
|
+
}
|
138
|
+
sliderValue = this.getNearestValue(sliderValue);
|
139
|
+
this.values[handleIdx] = sliderValue;
|
140
|
+
this.value = this.values[0]; // assure backwards compat
|
141
|
+
|
142
|
+
this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
|
143
|
+
this.translateToPx(sliderValue);
|
144
|
+
|
145
|
+
this.drawSpans();
|
146
|
+
if (!this.dragging || !this.event) this.updateFinished();
|
147
|
+
},
|
148
|
+
setValueBy: function(delta, handleIdx) {
|
149
|
+
this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
|
150
|
+
handleIdx || this.activeHandleIdx || 0);
|
151
|
+
},
|
152
|
+
translateToPx: function(value) {
|
153
|
+
return Math.round(
|
154
|
+
((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
|
155
|
+
(value - this.range.start)) + "px";
|
156
|
+
},
|
157
|
+
translateToValue: function(offset) {
|
158
|
+
return ((offset/(this.trackLength-this.handleLength) *
|
159
|
+
(this.range.end-this.range.start)) + this.range.start);
|
160
|
+
},
|
161
|
+
getRange: function(range) {
|
162
|
+
var v = this.values.sortBy(Prototype.K);
|
163
|
+
range = range || 0;
|
164
|
+
return $R(v[range],v[range+1]);
|
165
|
+
},
|
166
|
+
minimumOffset: function(){
|
167
|
+
return(this.isVertical() ? this.alignY : this.alignX);
|
168
|
+
},
|
169
|
+
maximumOffset: function(){
|
170
|
+
return(this.isVertical() ?
|
171
|
+
(this.track.offsetHeight != 0 ? this.track.offsetHeight :
|
172
|
+
this.track.style.height.replace(/px$/,"")) - this.alignY :
|
173
|
+
(this.track.offsetWidth != 0 ? this.track.offsetWidth :
|
174
|
+
this.track.style.width.replace(/px$/,"")) - this.alignX);
|
175
|
+
},
|
176
|
+
isVertical: function(){
|
177
|
+
return (this.axis == 'vertical');
|
178
|
+
},
|
179
|
+
drawSpans: function() {
|
180
|
+
var slider = this;
|
181
|
+
if (this.spans)
|
182
|
+
$R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
|
183
|
+
if (this.options.startSpan)
|
184
|
+
this.setSpan(this.options.startSpan,
|
185
|
+
$R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
|
186
|
+
if (this.options.endSpan)
|
187
|
+
this.setSpan(this.options.endSpan,
|
188
|
+
$R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
|
189
|
+
},
|
190
|
+
setSpan: function(span, range) {
|
191
|
+
if (this.isVertical()) {
|
192
|
+
span.style.top = this.translateToPx(range.start);
|
193
|
+
span.style.height = this.translateToPx(range.end - range.start + this.range.start);
|
194
|
+
} else {
|
195
|
+
span.style.left = this.translateToPx(range.start);
|
196
|
+
span.style.width = this.translateToPx(range.end - range.start + this.range.start);
|
197
|
+
}
|
198
|
+
},
|
199
|
+
updateStyles: function() {
|
200
|
+
this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
|
201
|
+
Element.addClassName(this.activeHandle, 'selected');
|
202
|
+
},
|
203
|
+
startDrag: function(event) {
|
204
|
+
if (Event.isLeftClick(event)) {
|
205
|
+
if (!this.disabled){
|
206
|
+
this.active = true;
|
207
|
+
|
208
|
+
var handle = Event.element(event);
|
209
|
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
210
|
+
var track = handle;
|
211
|
+
if (track==this.track) {
|
212
|
+
var offsets = this.track.cumulativeOffset();
|
213
|
+
this.event = event;
|
214
|
+
this.setValue(this.translateToValue(
|
215
|
+
(this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
|
216
|
+
));
|
217
|
+
var offsets = this.activeHandle.cumulativeOffset();
|
218
|
+
this.offsetX = (pointer[0] - offsets[0]);
|
219
|
+
this.offsetY = (pointer[1] - offsets[1]);
|
220
|
+
} else {
|
221
|
+
// find the handle (prevents issues with Safari)
|
222
|
+
while((this.handles.indexOf(handle) == -1) && handle.parentNode)
|
223
|
+
handle = handle.parentNode;
|
224
|
+
|
225
|
+
if (this.handles.indexOf(handle)!=-1) {
|
226
|
+
this.activeHandle = handle;
|
227
|
+
this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
|
228
|
+
this.updateStyles();
|
229
|
+
|
230
|
+
var offsets = this.activeHandle.cumulativeOffset();
|
231
|
+
this.offsetX = (pointer[0] - offsets[0]);
|
232
|
+
this.offsetY = (pointer[1] - offsets[1]);
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
Event.stop(event);
|
237
|
+
}
|
238
|
+
},
|
239
|
+
update: function(event) {
|
240
|
+
if (this.active) {
|
241
|
+
if (!this.dragging) this.dragging = true;
|
242
|
+
this.draw(event);
|
243
|
+
if (Prototype.Browser.WebKit) window.scrollBy(0,0);
|
244
|
+
Event.stop(event);
|
245
|
+
}
|
246
|
+
},
|
247
|
+
draw: function(event) {
|
248
|
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
249
|
+
var offsets = this.track.cumulativeOffset();
|
250
|
+
pointer[0] -= this.offsetX + offsets[0];
|
251
|
+
pointer[1] -= this.offsetY + offsets[1];
|
252
|
+
this.event = event;
|
253
|
+
this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
|
254
|
+
if (this.initialized && this.options.onSlide)
|
255
|
+
this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
|
256
|
+
},
|
257
|
+
endDrag: function(event) {
|
258
|
+
if (this.active && this.dragging) {
|
259
|
+
this.finishDrag(event, true);
|
260
|
+
Event.stop(event);
|
261
|
+
}
|
262
|
+
this.active = false;
|
263
|
+
this.dragging = false;
|
264
|
+
},
|
265
|
+
finishDrag: function(event, success) {
|
266
|
+
this.active = false;
|
267
|
+
this.dragging = false;
|
268
|
+
this.updateFinished();
|
269
|
+
},
|
270
|
+
updateFinished: function() {
|
271
|
+
if (this.initialized && this.options.onChange)
|
272
|
+
this.options.onChange(this.values.length>1 ? this.values : this.value, this);
|
273
|
+
this.event = null;
|
274
|
+
}
|
275
|
+
});
|
@@ -0,0 +1,59 @@
|
|
1
|
+
// script.aculo.us sound.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
|
2
|
+
|
3
|
+
// Copyright (c) 2005-2009 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 if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('Windows Media') != -1 }))
|
54
|
+
Sound.template = new Template('<object id="sound_#{track}_#{id}" type="application/x-mplayer2" data="#{url}"></object>');
|
55
|
+
else if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('RealPlayer') != -1 }))
|
56
|
+
Sound.template = new Template('<embed type="audio/x-pn-realaudio-plugin" style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>');
|
57
|
+
else
|
58
|
+
Sound.play = function(){};
|
59
|
+
}
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Ajaxlibs::IncludesHelper" do
|
4
|
+
before :all do
|
5
|
+
class FakeActionView
|
6
|
+
include Ajaxlibs::IncludesHelper
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
context "in development environment" do
|
11
|
+
before :all do
|
12
|
+
Object.send(:remove_const, 'RAILS_ENV') if Object.const_defined?('RAILS_ENV')
|
13
|
+
RAILS_ENV = 'development'
|
14
|
+
end
|
15
|
+
|
16
|
+
before :each do
|
17
|
+
@fake_action_view = FakeActionView.new
|
18
|
+
@fake_action_view.stub! :javascript_include_tag
|
19
|
+
end
|
20
|
+
|
21
|
+
context "should call javascript_include_tag to include local javascript library file" do
|
22
|
+
example "once if only one library was specified" do
|
23
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
24
|
+
with(Ajaxlibs::Library.by_name(:prototype).local_path).
|
25
|
+
once
|
26
|
+
|
27
|
+
@fake_action_view.ajaxlibs_include :prototype
|
28
|
+
end
|
29
|
+
|
30
|
+
example "once for each specified library" do
|
31
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
32
|
+
with(Ajaxlibs::Library.by_name(:prototype).local_path).
|
33
|
+
once
|
34
|
+
|
35
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
36
|
+
with(Ajaxlibs::Library.by_name(:scriptaculous).local_path).
|
37
|
+
once
|
38
|
+
|
39
|
+
@fake_action_view.ajaxlibs_include :prototype, :scriptaculous
|
40
|
+
end
|
41
|
+
|
42
|
+
example "once for each specified library and dependendencies" do
|
43
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
44
|
+
with(Ajaxlibs::Library.by_name(:prototype).local_path).
|
45
|
+
once
|
46
|
+
|
47
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
48
|
+
with(Ajaxlibs::Library.by_name(:scriptaculous).local_path).
|
49
|
+
once
|
50
|
+
|
51
|
+
@fake_action_view.ajaxlibs_include :scriptaculous
|
52
|
+
end
|
53
|
+
|
54
|
+
example "once for specified library, avoiding multiple includes" do
|
55
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
56
|
+
with(Ajaxlibs::Library.by_name(:prototype).local_path).
|
57
|
+
once.times
|
58
|
+
|
59
|
+
@fake_action_view.ajaxlibs_include :prototype, :prototype
|
60
|
+
end
|
61
|
+
|
62
|
+
context "while specifying a specific version number" do
|
63
|
+
example "once if one library was specified" do
|
64
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
65
|
+
with(Ajaxlibs::Library.by_name(:prototype).local_path('1.6.0.3')).
|
66
|
+
once
|
67
|
+
|
68
|
+
@fake_action_view.ajaxlibs_include :prototype, :version => '1.6.0.3'
|
69
|
+
end
|
70
|
+
end # end of context "while specifying a specific version number"
|
71
|
+
end # end of context "should call javascript_include_tag to include local javascript library file"
|
72
|
+
end # end of context "in development environment"
|
73
|
+
|
74
|
+
context "in production environment" do
|
75
|
+
before :all do
|
76
|
+
Object.send(:remove_const, 'RAILS_ENV') if Object.const_defined?('RAILS_ENV')
|
77
|
+
RAILS_ENV = 'production'
|
78
|
+
end
|
79
|
+
|
80
|
+
before :each do
|
81
|
+
@fake_action_view = FakeActionView.new
|
82
|
+
@fake_action_view.stub! :javascript_tag
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should include google jsapi script" do
|
86
|
+
@fake_action_view.ajaxlibs_include(:prototype).should include("<script type=\"text/javascript\" src=\"#{Ajaxlibs::GoogleJSAPI}\"></script>")
|
87
|
+
end
|
88
|
+
|
89
|
+
context "should call javascript_tag with google jsapi load code" do
|
90
|
+
example "once if only one library was specified" do
|
91
|
+
@fake_action_view.should_receive(:javascript_tag).
|
92
|
+
with(Ajaxlibs::Library.by_name(:prototype).google_cdn_load_code).
|
93
|
+
once
|
94
|
+
|
95
|
+
@fake_action_view.ajaxlibs_include :prototype
|
96
|
+
end
|
97
|
+
|
98
|
+
example "once for each specified library" do
|
99
|
+
@fake_action_view.should_receive(:javascript_tag).
|
100
|
+
with([
|
101
|
+
Ajaxlibs::Library.by_name(:prototype).google_cdn_load_code,
|
102
|
+
Ajaxlibs::Library.by_name(:scriptaculous).google_cdn_load_code
|
103
|
+
].join("\n")).
|
104
|
+
once
|
105
|
+
|
106
|
+
@fake_action_view.ajaxlibs_include :prototype, :scriptaculous
|
107
|
+
end
|
108
|
+
|
109
|
+
example "once for each specified library and dependendencies" do
|
110
|
+
@fake_action_view.should_receive(:javascript_tag).
|
111
|
+
with([
|
112
|
+
Ajaxlibs::Library.by_name(:prototype).google_cdn_load_code,
|
113
|
+
Ajaxlibs::Library.by_name(:scriptaculous).google_cdn_load_code
|
114
|
+
].join("\n")).
|
115
|
+
once
|
116
|
+
|
117
|
+
@fake_action_view.ajaxlibs_include :scriptaculous
|
118
|
+
end
|
119
|
+
|
120
|
+
example "once for specified library, avoiding multiple includes" do
|
121
|
+
@fake_action_view.should_receive(:javascript_tag).
|
122
|
+
with(Ajaxlibs::Library.by_name(:prototype).google_cdn_load_code).
|
123
|
+
once.times
|
124
|
+
|
125
|
+
@fake_action_view.ajaxlibs_include :prototype, :prototype
|
126
|
+
end
|
127
|
+
|
128
|
+
context "while specifying a specific version number" do
|
129
|
+
example "once if one library was specified" do
|
130
|
+
@fake_action_view.should_receive(:javascript_tag).
|
131
|
+
with(Ajaxlibs::Library.by_name(:prototype).google_cdn_load_code('1.6.0.3')).
|
132
|
+
once.times
|
133
|
+
|
134
|
+
@fake_action_view.ajaxlibs_include :prototype, :version => '1.6.0.3'
|
135
|
+
end
|
136
|
+
end # end of context "while specifying a specific version number"
|
137
|
+
end # end of context "should call javascript_tag with google jsapi load code"
|
138
|
+
end # end of context "in production environment"
|
139
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
class Ajaxlibs::Library::Basic < Ajaxlibs::Library
|
4
|
+
Versions = ['0.1',
|
5
|
+
'1.4.9',
|
6
|
+
'1.5',
|
7
|
+
'1.8.1',
|
8
|
+
'2.0.1.3']
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "Ajaxlibs::Library" do
|
12
|
+
context "class" do
|
13
|
+
it "should returns library name based on its class name" do
|
14
|
+
Ajaxlibs::Library::Basic.library_name.should == 'basic'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "instance" do
|
19
|
+
before :each do
|
20
|
+
@library = Ajaxlibs::Library::Basic.new
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should returns latest version" do
|
24
|
+
@library.latest_version.should == '2.0.1.3'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should determine library_name by its own class name" do
|
28
|
+
@library.library_name.should == 'basic'
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should use library_name as file_name by default" do
|
32
|
+
@library.library_name.should == @library.file_name
|
33
|
+
end
|
34
|
+
|
35
|
+
context "will return a local path composed of library_name, version and file_name" do
|
36
|
+
example "using provided version if specified" do
|
37
|
+
@library.local_path('1.8.1').should == "ajaxlibs/basic/1.8.1/basic"
|
38
|
+
end
|
39
|
+
|
40
|
+
example "using latest version if none was specified" do
|
41
|
+
@library.local_path.should == "ajaxlibs/basic/2.0.1.3/basic"
|
42
|
+
end
|
43
|
+
|
44
|
+
example "unless version was wrong" do
|
45
|
+
lambda { @library.local_path('42') }.should raise_error(Ajaxlibs::Exception::VersionNotFound)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "will return a javascript code to load from google cdn with library_name and version" do
|
50
|
+
example "using provided version if specified" do
|
51
|
+
@library.google_cdn_load_code('1.8.1').should == "google.load('basic', '1.8.1');"
|
52
|
+
end
|
53
|
+
|
54
|
+
example "using latest version if none was specified" do
|
55
|
+
@library.google_cdn_load_code.should == "google.load('basic', '2.0.1.3');"
|
56
|
+
end
|
57
|
+
|
58
|
+
example "unless version was wrong" do
|
59
|
+
lambda { @library.google_cdn_load_code('42') }.should raise_error(Ajaxlibs::Exception::VersionNotFound)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "base class" do
|
65
|
+
example "will return the right instance while searching by name" do
|
66
|
+
Ajaxlibs::Library.by_name(:jquery).should be_kind_of(Ajaxlibs::Library::Jquery)
|
67
|
+
end
|
68
|
+
|
69
|
+
example "will raise an exception if library is not found" do
|
70
|
+
lambda { Ajaxlibs::Library.by_name(:foo) }.should raise_error(Ajaxlibs::Exception::LibraryNotFound)
|
71
|
+
end
|
72
|
+
|
73
|
+
example "will register class by name when inherited" do
|
74
|
+
Ajaxlibs::Library.should_not have_registered_child_class(:foo)
|
75
|
+
lambda { Ajaxlibs::Library.by_name(:foo) }.should raise_error(Ajaxlibs::Exception::LibraryNotFound)
|
76
|
+
class Ajaxlibs::Library::Foo < Ajaxlibs::Library
|
77
|
+
end
|
78
|
+
Ajaxlibs::Library.should have_registered_child_class(:foo)
|
79
|
+
Ajaxlibs::Library.all.should include(Ajaxlibs::Library::Foo)
|
80
|
+
Ajaxlibs::Library.by_name(:foo).should be_kind_of(Ajaxlibs::Library::Foo)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'ajaxlibs'
|
4
|
+
require 'spec'
|
5
|
+
require 'spec/autorun'
|
6
|
+
|
7
|
+
Spec::Runner.configure do |config|
|
8
|
+
end
|
9
|
+
|
10
|
+
Spec::Matchers.define :have_registered_child_class do |child_class|
|
11
|
+
match do |base_class|
|
12
|
+
base_class.class_eval("@@subclasses.keys.include?(:#{child_class})")
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Ajaxlibs::VersionTools" do
|
4
|
+
it "should accept equity" do
|
5
|
+
Ajaxlibs::VersionsTools.compare('2.52.6', '2.52.6').should == 0
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should handle major version difference" do
|
9
|
+
Ajaxlibs::VersionsTools.compare('3', '2' ).should == 1
|
10
|
+
Ajaxlibs::VersionsTools.compare('3.4', '2.4' ).should == 1
|
11
|
+
Ajaxlibs::VersionsTools.compare('3.4', '2.4.5').should == 1
|
12
|
+
|
13
|
+
Ajaxlibs::VersionsTools.compare('2', '3' ).should == -1
|
14
|
+
Ajaxlibs::VersionsTools.compare('2.4', '3.4' ).should == -1
|
15
|
+
Ajaxlibs::VersionsTools.compare('2.4.5', '3.4.5').should == -1
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should handle minor version difference" do
|
19
|
+
Ajaxlibs::VersionsTools.compare('3.4', '3.1' ).should == 1
|
20
|
+
Ajaxlibs::VersionsTools.compare('3.4', '3.24' ).should == 1
|
21
|
+
Ajaxlibs::VersionsTools.compare('3.4', '3.3.5').should == 1
|
22
|
+
|
23
|
+
Ajaxlibs::VersionsTools.compare('3.1', '3.4').should == -1
|
24
|
+
Ajaxlibs::VersionsTools.compare('3.24', '3.4').should == -1
|
25
|
+
Ajaxlibs::VersionsTools.compare('3.3.5', '3.4').should == -1
|
26
|
+
end
|
27
|
+
end
|