bivouac 0.1.4 → 0.1.5
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/README +6 -7
- data/bin/bivouac +1 -1
- data/doc/rdoc/classes/BivouacHelpers/BaseView.html +178 -0
- data/doc/rdoc/classes/BivouacHelpers/FormView.html +398 -0
- data/doc/rdoc/classes/BivouacHelpers/HtmlView.html +305 -0
- data/doc/rdoc/classes/BivouacHelpers/JavaScriptView.html +573 -0
- data/doc/rdoc/classes/BivouacHelpers/ScriptAculoUsView.html +258 -0
- data/doc/rdoc/classes/BivouacHelpers/TooltipView.html +158 -0
- data/doc/rdoc/classes/BivouacHelpers.html +117 -0
- data/doc/rdoc/classes/JavaScriptGenerator.html +564 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/AUTHORS.html +109 -0
- data/doc/rdoc/files/COPYING.html +533 -0
- data/doc/rdoc/files/README.html +427 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/base_rb.html +109 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/form_rb.html +109 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/html_rb.html +109 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/javascript_rb.html +113 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/scriptaculous_rb.html +113 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/tooltip_rb.html +109 -0
- data/doc/rdoc/index.html +10 -0
- data/doc/rdoc/permalink.gif +0 -0
- data/doc/rdoc/rdoc-style.css +106 -0
- data/doc/rdoc/rubyfr.png +0 -0
- data/examples/bivouac_sample/Rakefile +48 -0
- data/examples/bivouac_sample/app/bivouac_sample.rb +15 -7
- data/examples/bivouac_sample/app/controllers/index.rb +2 -2
- data/examples/bivouac_sample/app/controllers/sound.rb +10 -0
- data/examples/bivouac_sample/app/helpers/_helpers.rb +6 -3
- data/examples/bivouac_sample/app/views/sound.rb +16 -0
- data/examples/bivouac_sample/config/environment.rb +5 -2
- data/examples/bivouac_sample/config/postamble.rb +89 -18
- data/examples/bivouac_sample/public/javascripts/builder.js +12 -7
- data/examples/bivouac_sample/public/javascripts/controls.js +485 -355
- data/examples/bivouac_sample/public/javascripts/dragdrop.js +82 -52
- data/examples/bivouac_sample/public/javascripts/effects.js +361 -329
- data/examples/bivouac_sample/public/javascripts/prototype.js +2826 -1120
- data/examples/bivouac_sample/public/javascripts/scriptaculous.js +15 -8
- data/examples/bivouac_sample/public/javascripts/slider.js +40 -43
- data/examples/bivouac_sample/public/javascripts/sound.js +55 -0
- data/examples/bivouac_sample/public/javascripts/unittest.js +16 -12
- data/examples/bivouac_sample/public/sound/sword.mp3 +0 -0
- data/examples/bivouac_sample/script/console +6 -0
- data/examples/bivouac_sample/script/plugin +3 -0
- data/examples/bivouac_sample/script/server +2 -1
- data/examples/bivouac_sample/test/test_sound.rb +15 -0
- data/lib/bivouac/helpers/view/goh/sound.rb +38 -0
- data/lib/bivouac/template/application/helpers_goh.rb +2 -0
- data/lib/bivouac/template/static/builder.js +12 -7
- data/lib/bivouac/template/static/controls.js +485 -355
- data/lib/bivouac/template/static/dragdrop.js +82 -52
- data/lib/bivouac/template/static/effects.js +361 -329
- data/lib/bivouac/template/static/prototype.js +2826 -1120
- data/lib/bivouac/template/static/scriptaculous.js +15 -8
- data/lib/bivouac/template/static/slider.js +40 -43
- data/lib/bivouac/template/static/sound.js +55 -0
- data/lib/bivouac/template/static/unittest.js +16 -12
- metadata +45 -2
@@ -1,12 +1,12 @@
|
|
1
|
-
// script.aculo.us dragdrop.js v1.
|
1
|
+
// script.aculo.us dragdrop.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
|
2
2
|
|
3
|
-
// Copyright (c) 2005
|
4
|
-
// (c) 2005
|
3
|
+
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
4
|
+
// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
|
5
5
|
//
|
6
6
|
// script.aculo.us is freely distributable under the terms of an MIT-style license.
|
7
7
|
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
8
8
|
|
9
|
-
if(
|
9
|
+
if(Object.isUndefined(Effect))
|
10
10
|
throw("dragdrop.js requires including script.aculo.us' effects.js library");
|
11
11
|
|
12
12
|
var Droppables = {
|
@@ -22,14 +22,13 @@ var Droppables = {
|
|
22
22
|
greedy: true,
|
23
23
|
hoverclass: null,
|
24
24
|
tree: false
|
25
|
-
}, arguments[1] || {});
|
25
|
+
}, arguments[1] || { });
|
26
26
|
|
27
27
|
// cache containers
|
28
28
|
if(options.containment) {
|
29
29
|
options._containers = [];
|
30
30
|
var containment = options.containment;
|
31
|
-
if((
|
32
|
-
(containment.constructor == Array)) {
|
31
|
+
if(Object.isArray(containment)) {
|
33
32
|
containment.each( function(c) { options._containers.push($(c)) });
|
34
33
|
} else {
|
35
34
|
options._containers.push($(containment));
|
@@ -89,21 +88,23 @@ var Droppables = {
|
|
89
88
|
|
90
89
|
show: function(point, element) {
|
91
90
|
if(!this.drops.length) return;
|
92
|
-
var affected = [];
|
91
|
+
var drop, affected = [];
|
93
92
|
|
94
|
-
if(this.last_active) this.deactivate(this.last_active);
|
95
93
|
this.drops.each( function(drop) {
|
96
94
|
if(Droppables.isAffected(point, element, drop))
|
97
95
|
affected.push(drop);
|
98
96
|
});
|
99
97
|
|
100
|
-
if(affected.length>0)
|
98
|
+
if(affected.length>0)
|
101
99
|
drop = Droppables.findDeepestChild(affected);
|
100
|
+
|
101
|
+
if(this.last_active && this.last_active != drop) this.deactivate(this.last_active);
|
102
|
+
if (drop) {
|
102
103
|
Position.within(drop.element, point[0], point[1]);
|
103
104
|
if(drop.onHover)
|
104
105
|
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
|
105
106
|
|
106
|
-
Droppables.activate(drop);
|
107
|
+
if (drop != this.last_active) Droppables.activate(drop);
|
107
108
|
}
|
108
109
|
},
|
109
110
|
|
@@ -112,8 +113,10 @@ var Droppables = {
|
|
112
113
|
Position.prepare();
|
113
114
|
|
114
115
|
if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
|
115
|
-
if (this.last_active.onDrop)
|
116
|
-
this.last_active.onDrop(element, this.last_active.element, event);
|
116
|
+
if (this.last_active.onDrop) {
|
117
|
+
this.last_active.onDrop(element, this.last_active.element, event);
|
118
|
+
return true;
|
119
|
+
}
|
117
120
|
},
|
118
121
|
|
119
122
|
reset: function() {
|
@@ -221,10 +224,7 @@ var Draggables = {
|
|
221
224
|
|
222
225
|
/*--------------------------------------------------------------------------*/
|
223
226
|
|
224
|
-
var Draggable = Class.create(
|
225
|
-
Draggable._dragging = {};
|
226
|
-
|
227
|
-
Draggable.prototype = {
|
227
|
+
var Draggable = Class.create({
|
228
228
|
initialize: function(element) {
|
229
229
|
var defaults = {
|
230
230
|
handle: false,
|
@@ -235,7 +235,7 @@ Draggable.prototype = {
|
|
235
235
|
});
|
236
236
|
},
|
237
237
|
endeffect: function(element) {
|
238
|
-
var toOpacity =
|
238
|
+
var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
|
239
239
|
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
|
240
240
|
queue: {scope:'_draggable', position:'end'},
|
241
241
|
afterFinish: function(){
|
@@ -245,6 +245,7 @@ Draggable.prototype = {
|
|
245
245
|
},
|
246
246
|
zindex: 1000,
|
247
247
|
revert: false,
|
248
|
+
quiet: false,
|
248
249
|
scroll: false,
|
249
250
|
scrollSensitivity: 20,
|
250
251
|
scrollSpeed: 15,
|
@@ -252,7 +253,7 @@ Draggable.prototype = {
|
|
252
253
|
delay: 0
|
253
254
|
};
|
254
255
|
|
255
|
-
if(!arguments[1] ||
|
256
|
+
if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
|
256
257
|
Object.extend(defaults, {
|
257
258
|
starteffect: function(element) {
|
258
259
|
element._opacity = Element.getOpacity(element);
|
@@ -261,11 +262,11 @@ Draggable.prototype = {
|
|
261
262
|
}
|
262
263
|
});
|
263
264
|
|
264
|
-
var options = Object.extend(defaults, arguments[1] || {});
|
265
|
+
var options = Object.extend(defaults, arguments[1] || { });
|
265
266
|
|
266
267
|
this.element = $(element);
|
267
268
|
|
268
|
-
if(options.handle && (
|
269
|
+
if(options.handle && Object.isString(options.handle))
|
269
270
|
this.handle = this.element.down('.'+options.handle, 0);
|
270
271
|
|
271
272
|
if(!this.handle) this.handle = $(options.handle);
|
@@ -278,7 +279,6 @@ Draggable.prototype = {
|
|
278
279
|
|
279
280
|
Element.makePositioned(this.element); // fix IE
|
280
281
|
|
281
|
-
this.delta = this.currentDelta();
|
282
282
|
this.options = options;
|
283
283
|
this.dragging = false;
|
284
284
|
|
@@ -300,7 +300,7 @@ Draggable.prototype = {
|
|
300
300
|
},
|
301
301
|
|
302
302
|
initDrag: function(event) {
|
303
|
-
if(
|
303
|
+
if(!Object.isUndefined(Draggable._dragging[this.element]) &&
|
304
304
|
Draggable._dragging[this.element]) return;
|
305
305
|
if(Event.isLeftClick(event)) {
|
306
306
|
// abort on form elements, fixes a Firefox issue
|
@@ -323,6 +323,8 @@ Draggable.prototype = {
|
|
323
323
|
|
324
324
|
startDrag: function(event) {
|
325
325
|
this.dragging = true;
|
326
|
+
if(!this.delta)
|
327
|
+
this.delta = this.currentDelta();
|
326
328
|
|
327
329
|
if(this.options.zindex) {
|
328
330
|
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
|
@@ -331,7 +333,9 @@ Draggable.prototype = {
|
|
331
333
|
|
332
334
|
if(this.options.ghosting) {
|
333
335
|
this._clone = this.element.cloneNode(true);
|
334
|
-
|
336
|
+
this.element._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
|
337
|
+
if (!this.element._originallyAbsolute)
|
338
|
+
Position.absolutize(this.element);
|
335
339
|
this.element.parentNode.insertBefore(this._clone, this.element);
|
336
340
|
}
|
337
341
|
|
@@ -353,8 +357,12 @@ Draggable.prototype = {
|
|
353
357
|
|
354
358
|
updateDrag: function(event, pointer) {
|
355
359
|
if(!this.dragging) this.startDrag(event);
|
356
|
-
|
357
|
-
|
360
|
+
|
361
|
+
if(!this.options.quiet){
|
362
|
+
Position.prepare();
|
363
|
+
Droppables.show(pointer, this.element);
|
364
|
+
}
|
365
|
+
|
358
366
|
Draggables.notify('onDrag', this, event);
|
359
367
|
|
360
368
|
this.draw(pointer);
|
@@ -382,30 +390,44 @@ Draggable.prototype = {
|
|
382
390
|
}
|
383
391
|
|
384
392
|
// fix AppleWebKit rendering
|
385
|
-
if(
|
393
|
+
if(Prototype.Browser.WebKit) window.scrollBy(0,0);
|
386
394
|
|
387
395
|
Event.stop(event);
|
388
396
|
},
|
389
397
|
|
390
398
|
finishDrag: function(event, success) {
|
391
399
|
this.dragging = false;
|
400
|
+
|
401
|
+
if(this.options.quiet){
|
402
|
+
Position.prepare();
|
403
|
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
404
|
+
Droppables.show(pointer, this.element);
|
405
|
+
}
|
392
406
|
|
393
407
|
if(this.options.ghosting) {
|
394
|
-
|
408
|
+
if (!this.element._originallyAbsolute)
|
409
|
+
Position.relativize(this.element);
|
410
|
+
delete this.element._originallyAbsolute;
|
395
411
|
Element.remove(this._clone);
|
396
412
|
this._clone = null;
|
397
413
|
}
|
398
414
|
|
399
|
-
|
415
|
+
var dropped = false;
|
416
|
+
if(success) {
|
417
|
+
dropped = Droppables.fire(event, this.element);
|
418
|
+
if (!dropped) dropped = false;
|
419
|
+
}
|
420
|
+
if(dropped && this.options.onDropped) this.options.onDropped(this.element);
|
400
421
|
Draggables.notify('onEnd', this, event);
|
401
422
|
|
402
423
|
var revert = this.options.revert;
|
403
|
-
if(revert &&
|
424
|
+
if(revert && Object.isFunction(revert)) revert = revert(this.element);
|
404
425
|
|
405
426
|
var d = this.currentDelta();
|
406
427
|
if(revert && this.options.reverteffect) {
|
407
|
-
|
408
|
-
|
428
|
+
if (dropped == 0 || revert != 'failure')
|
429
|
+
this.options.reverteffect(this.element,
|
430
|
+
d[1]-this.delta[1], d[0]-this.delta[0]);
|
409
431
|
} else {
|
410
432
|
this.delta = d;
|
411
433
|
}
|
@@ -453,15 +475,15 @@ Draggable.prototype = {
|
|
453
475
|
}.bind(this));
|
454
476
|
|
455
477
|
if(this.options.snap) {
|
456
|
-
if(
|
478
|
+
if(Object.isFunction(this.options.snap)) {
|
457
479
|
p = this.options.snap(p[0],p[1],this);
|
458
480
|
} else {
|
459
|
-
if(this.options.snap
|
481
|
+
if(Object.isArray(this.options.snap)) {
|
460
482
|
p = p.map( function(v, i) {
|
461
|
-
return
|
483
|
+
return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this))
|
462
484
|
} else {
|
463
485
|
p = p.map( function(v) {
|
464
|
-
return
|
486
|
+
return (v/this.options.snap).round()*this.options.snap }.bind(this))
|
465
487
|
}
|
466
488
|
}}
|
467
489
|
|
@@ -545,12 +567,13 @@ Draggable.prototype = {
|
|
545
567
|
}
|
546
568
|
return { top: T, left: L, width: W, height: H };
|
547
569
|
}
|
548
|
-
}
|
570
|
+
});
|
571
|
+
|
572
|
+
Draggable._dragging = { };
|
549
573
|
|
550
574
|
/*--------------------------------------------------------------------------*/
|
551
575
|
|
552
|
-
var SortableObserver = Class.create(
|
553
|
-
SortableObserver.prototype = {
|
576
|
+
var SortableObserver = Class.create({
|
554
577
|
initialize: function(element, observer) {
|
555
578
|
this.element = $(element);
|
556
579
|
this.observer = observer;
|
@@ -566,12 +589,12 @@ SortableObserver.prototype = {
|
|
566
589
|
if(this.lastValue != Sortable.serialize(this.element))
|
567
590
|
this.observer(this.element)
|
568
591
|
}
|
569
|
-
}
|
592
|
+
});
|
570
593
|
|
571
594
|
var Sortable = {
|
572
595
|
SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
|
573
596
|
|
574
|
-
sortables: {},
|
597
|
+
sortables: { },
|
575
598
|
|
576
599
|
_findRootElement: function(element) {
|
577
600
|
while (element.tagName.toUpperCase() != "BODY") {
|
@@ -614,13 +637,20 @@ var Sortable = {
|
|
614
637
|
delay: 0,
|
615
638
|
hoverclass: null,
|
616
639
|
ghosting: false,
|
640
|
+
quiet: false,
|
617
641
|
scroll: false,
|
618
642
|
scrollSensitivity: 20,
|
619
643
|
scrollSpeed: 15,
|
620
644
|
format: this.SERIALIZE_RULE,
|
645
|
+
|
646
|
+
// these take arrays of elements or ids and can be
|
647
|
+
// used for better initialization performance
|
648
|
+
elements: false,
|
649
|
+
handles: false,
|
650
|
+
|
621
651
|
onChange: Prototype.emptyFunction,
|
622
652
|
onUpdate: Prototype.emptyFunction
|
623
|
-
}, arguments[1] || {});
|
653
|
+
}, arguments[1] || { });
|
624
654
|
|
625
655
|
// clear any old sortable with same element
|
626
656
|
this.destroy(element);
|
@@ -628,6 +658,7 @@ var Sortable = {
|
|
628
658
|
// build options for the draggables
|
629
659
|
var options_for_draggable = {
|
630
660
|
revert: true,
|
661
|
+
quiet: options.quiet,
|
631
662
|
scroll: options.scroll,
|
632
663
|
scrollSpeed: options.scrollSpeed,
|
633
664
|
scrollSensitivity: options.scrollSensitivity,
|
@@ -681,10 +712,9 @@ var Sortable = {
|
|
681
712
|
options.droppables.push(element);
|
682
713
|
}
|
683
714
|
|
684
|
-
(this.findElements(element, options) || []).each( function(e) {
|
685
|
-
|
686
|
-
|
687
|
-
$(e).down('.'+options.handle,0) : e;
|
715
|
+
(options.elements || this.findElements(element, options) || []).each( function(e,i) {
|
716
|
+
var handle = options.handles ? $(options.handles[i]) :
|
717
|
+
(options.handle ? $(e).select('.' + options.handle)[0] : e);
|
688
718
|
options.draggables.push(
|
689
719
|
new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
|
690
720
|
Droppables.add(e, options_for_droppable);
|
@@ -844,7 +874,7 @@ var Sortable = {
|
|
844
874
|
only: sortableOptions.only,
|
845
875
|
name: element.id,
|
846
876
|
format: sortableOptions.format
|
847
|
-
}, arguments[1] || {});
|
877
|
+
}, arguments[1] || { });
|
848
878
|
|
849
879
|
var root = {
|
850
880
|
id: null,
|
@@ -868,7 +898,7 @@ var Sortable = {
|
|
868
898
|
|
869
899
|
sequence: function(element) {
|
870
900
|
element = $(element);
|
871
|
-
var options = Object.extend(this.options(element), arguments[1] || {});
|
901
|
+
var options = Object.extend(this.options(element), arguments[1] || { });
|
872
902
|
|
873
903
|
return $(this.findElements(element, options) || []).map( function(item) {
|
874
904
|
return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
|
@@ -877,9 +907,9 @@ var Sortable = {
|
|
877
907
|
|
878
908
|
setSequence: function(element, new_sequence) {
|
879
909
|
element = $(element);
|
880
|
-
var options = Object.extend(this.options(element), arguments[2] || {});
|
910
|
+
var options = Object.extend(this.options(element), arguments[2] || { });
|
881
911
|
|
882
|
-
var nodeMap = {};
|
912
|
+
var nodeMap = { };
|
883
913
|
this.findElements(element, options).each( function(n) {
|
884
914
|
if (n.id.match(options.format))
|
885
915
|
nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
|
@@ -897,7 +927,7 @@ var Sortable = {
|
|
897
927
|
|
898
928
|
serialize: function(element) {
|
899
929
|
element = $(element);
|
900
|
-
var options = Object.extend(Sortable.options(element), arguments[1] || {});
|
930
|
+
var options = Object.extend(Sortable.options(element), arguments[1] || { });
|
901
931
|
var name = encodeURIComponent(
|
902
932
|
(arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
|
903
933
|
|
@@ -921,7 +951,7 @@ Element.isParent = function(child, element) {
|
|
921
951
|
return Element.isParent(child.parentNode, element);
|
922
952
|
}
|
923
953
|
|
924
|
-
Element.findChildren = function(element, only, recursive, tagName) {
|
954
|
+
Element.findChildren = function(element, only, recursive, tagName) {
|
925
955
|
if(!element.hasChildNodes()) return null;
|
926
956
|
tagName = tagName.toUpperCase();
|
927
957
|
if(only) only = [only].flatten();
|