summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/effects
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/Javascripts/effects')
-rw-r--r--framework/Web/Javascripts/effects/controls.js10
-rw-r--r--framework/Web/Javascripts/effects/dragdrop.js34
-rw-r--r--framework/Web/Javascripts/effects/effects.js59
-rw-r--r--framework/Web/Javascripts/effects/slider.js21
4 files changed, 78 insertions, 46 deletions
diff --git a/framework/Web/Javascripts/effects/controls.js b/framework/Web/Javascripts/effects/controls.js
index de0261ed..ea5ce6ea 100644
--- a/framework/Web/Javascripts/effects/controls.js
+++ b/framework/Web/Javascripts/effects/controls.js
@@ -33,6 +33,9 @@
// useful when one of the tokens is \n (a newline), as it
// allows smart autocompletion after linebreaks.
+if(typeof Effect == 'undefined')
+ throw("controls.js requires including script.aculo.us' effects.js library");
+
var Autocompleter = {}
Autocompleter.Base = function() {};
Autocompleter.Base.prototype = {
@@ -94,7 +97,7 @@ Autocompleter.Base.prototype = {
},
fixIEOverlapping: function() {
- Position.clone(this.update, this.iefix);
+ Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
this.iefix.style.zIndex = 1;
this.update.style.zIndex = 2;
Element.show(this.iefix);
@@ -202,11 +205,13 @@ Autocompleter.Base.prototype = {
markPrevious: function() {
if(this.index > 0) this.index--
else this.index = this.entryCount-1;
+ this.getEntry(this.index).scrollIntoView(true);
},
markNext: function() {
if(this.index < this.entryCount-1) this.index++
else this.index = 0;
+ this.getEntry(this.index).scrollIntoView(false);
},
getEntry: function(index) {
@@ -531,7 +536,7 @@ Ajax.InPlaceEditor.prototype = {
Element.hide(this.element);
this.createForm();
this.element.parentNode.insertBefore(this.form, this.element);
- Field.scrollFreeActivate(this.editField);
+ if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField);
// stop the event to avoid a page refresh in Safari
if (evt) {
Event.stop(evt);
@@ -636,6 +641,7 @@ Ajax.InPlaceEditor.prototype = {
Element.removeClassName(this.form, this.options.loadingClassName);
this.editField.disabled = false;
this.editField.value = transport.responseText.stripTags();
+ Field.scrollFreeActivate(this.editField);
},
onclickCancel: function() {
this.onComplete();
diff --git a/framework/Web/Javascripts/effects/dragdrop.js b/framework/Web/Javascripts/effects/dragdrop.js
index be2a30f5..1528eced 100644
--- a/framework/Web/Javascripts/effects/dragdrop.js
+++ b/framework/Web/Javascripts/effects/dragdrop.js
@@ -5,6 +5,9 @@
/*--------------------------------------------------------------------------*/
+if(typeof Effect == 'undefined')
+ throw("dragdrop.js requires including script.aculo.us' effects.js library");
+
var Droppables = {
drops: [],
@@ -204,21 +207,31 @@ var Draggables = {
/*--------------------------------------------------------------------------*/
var Draggable = Class.create();
+Draggable._revertCache = {};
+Draggable._dragging = {};
+
Draggable.prototype = {
initialize: function(element) {
var options = Object.extend({
handle: false,
starteffect: function(element) {
- element._opacity = Element.getOpacity(element);
+ element._opacity = Element.getOpacity(element);
+ Draggable._dragging[element] = true;
new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
},
reverteffect: function(element, top_offset, left_offset) {
var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
- element._revert = new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur});
+ Draggable._revertCache[element] =
+ new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur,
+ queue: {scope:'_draggable', position:'end'}
+ });
},
endeffect: function(element) {
- var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0
- new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity});
+ var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0;
+ new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
+ queue: {scope:'_draggable', position:'end'},
+ afterFinish: function(){ Draggable._dragging[element] = false }
+ });
},
zindex: 1000,
revert: false,
@@ -264,6 +277,8 @@ Draggable.prototype = {
},
initDrag: function(event) {
+ if(typeof Draggable._dragging[this.element] != undefined &&
+ Draggable._dragging[this.element]) return;
if(Event.isLeftClick(event)) {
// abort on form elements, fixes a Firefox issue
var src = Event.element(event);
@@ -274,9 +289,9 @@ Draggable.prototype = {
src.tagName=='BUTTON' ||
src.tagName=='TEXTAREA')) return;
- if(this.element._revert) {
- this.element._revert.cancel();
- this.element._revert = null;
+ if(Draggable._revertCache[this.element]) {
+ Draggable._revertCache[this.element].cancel();
+ Draggable._revertCache[this.element] = null;
}
var pointer = [Event.pointerX(event), Event.pointerY(event)];
@@ -442,6 +457,7 @@ Draggable.prototype = {
},
startScrolling: function(speed) {
+ if(!(speed[0] || speed[1])) return;
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
this.lastScrolled = new Date();
this.scrollInterval = setInterval(this.scroll.bind(this), 10);
@@ -708,7 +724,7 @@ var Sortable = {
if(!Element.isParent(dropon, element)) {
var index;
- var children = Sortable.findElements(dropon, {tag: droponOptions.tag});
+ var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
var child = null;
if(children) {
@@ -869,7 +885,7 @@ var Sortable = {
if (options.tree) {
return Sortable.tree(element, arguments[1]).children.map( function (item) {
- return [name + Sortable._constructIndex(item) + "=" +
+ return [name + Sortable._constructIndex(item) + "[id]=" +
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
}).flatten().join('&');
} else {
diff --git a/framework/Web/Javascripts/effects/effects.js b/framework/Web/Javascripts/effects/effects.js
index 0864323e..1f3d50bb 100644
--- a/framework/Web/Javascripts/effects/effects.js
+++ b/framework/Web/Javascripts/effects/effects.js
@@ -105,6 +105,9 @@ Array.prototype.call = function() {
var Effect = {
tagifyText: function(element) {
+ if(typeof Builder == 'undefined')
+ throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
+
var tagifyStyle = 'position:relative';
if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1';
element = $(element);
@@ -161,9 +164,8 @@ var Effect2 = Effect; // deprecated
Effect.Transitions = {}
-Effect.Transitions.linear = function(pos) {
- return pos;
-}
+Effect.Transitions.linear = Prototype.K;
+
Effect.Transitions.sinoidal = function(pos) {
return (-Math.cos(pos*Math.PI)/2) + 0.5;
}
@@ -353,7 +355,7 @@ Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
initialize: function(element) {
this.element = $(element);
// make this work on IE on elements without 'layout'
- if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
+ if(/MSIE/.test(navigator.userAgent) && (!this.element.currentStyle.hasLayout))
this.element.setStyle({zoom: 1});
var options = Object.extend({
from: this.element.getOpacity() || 0.0,
@@ -393,8 +395,8 @@ Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
},
update: function(position) {
this.element.setStyle({
- left: this.options.x * position + this.originalLeft + 'px',
- top: this.options.y * position + this.originalTop + 'px'
+ left: Math.round(this.options.x * position + this.originalLeft) + 'px',
+ top: Math.round(this.options.y * position + this.originalTop) + 'px'
});
}
});
@@ -433,7 +435,7 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
this.originalLeft = this.element.offsetLeft;
var fontSize = this.element.getStyle('font-size') || '100%';
- ['em','px','%'].each( function(fontSizeType) {
+ ['em','px','%','pt'].each( function(fontSizeType) {
if(fontSize.indexOf(fontSizeType)>0) {
this.fontSize = parseFloat(fontSize);
this.fontSizeType = fontSizeType;
@@ -462,8 +464,8 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
},
setDimensions: function(height, width) {
var d = {};
- if(this.options.scaleX) d.width = width + 'px';
- if(this.options.scaleY) d.height = height + 'px';
+ if(this.options.scaleX) d.width = Math.round(width) + 'px';
+ if(this.options.scaleY) d.height = Math.round(height) + 'px';
if(this.options.scaleFromCenter) {
var topd = (height - this.dims[0])/2;
var leftd = (width - this.dims[1])/2;
@@ -589,7 +591,7 @@ Effect.Puff = function(element) {
Effect.BlindUp = function(element) {
element = $(element);
element.makeClipping();
- return new Effect.Scale(element, 0,
+ return new Effect.Scale(element, 0,
Object.extend({ scaleContent: false,
scaleX: false,
restoreAfterFinish: true,
@@ -604,28 +606,27 @@ Effect.BlindUp = function(element) {
Effect.BlindDown = function(element) {
element = $(element);
var elementDimensions = element.getDimensions();
- return new Effect.Scale(element, 100,
- Object.extend({ scaleContent: false,
- scaleX: false,
- scaleFrom: 0,
- scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
- restoreAfterFinish: true,
- afterSetup: function(effect) {
- effect.element.makeClipping();
- effect.element.setStyle({height: '0px'});
- effect.element.show();
- },
- afterFinishInternal: function(effect) {
- effect.element.undoClipping();
- }
- }, arguments[1] || {})
- );
+ return new Effect.Scale(element, 100, Object.extend({
+ scaleContent: false,
+ scaleX: false,
+ scaleFrom: 0,
+ scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
+ restoreAfterFinish: true,
+ afterSetup: function(effect) {
+ effect.element.makeClipping();
+ effect.element.setStyle({height: '0px'});
+ effect.element.show();
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.undoClipping();
+ }
+ }, arguments[1] || {}));
}
Effect.SwitchOff = function(element) {
element = $(element);
var oldOpacity = element.getInlineOpacity();
- return new Effect.Appear(element, {
+ return new Effect.Appear(element, Object.extend({
duration: 0.4,
from: 0,
transition: Effect.Transitions.flicker,
@@ -645,7 +646,7 @@ Effect.SwitchOff = function(element) {
}
})
}
- });
+ }, arguments[1] || {}));
}
Effect.DropOut = function(element) {
@@ -729,7 +730,7 @@ Effect.SlideDown = function(element) {
}, arguments[1] || {})
);
}
-
+
Effect.SlideUp = function(element) {
element = $(element);
element.cleanWhitespace();
diff --git a/framework/Web/Javascripts/effects/slider.js b/framework/Web/Javascripts/effects/slider.js
index c0f1fc01..696992ca 100644
--- a/framework/Web/Javascripts/effects/slider.js
+++ b/framework/Web/Javascripts/effects/slider.js
@@ -64,7 +64,12 @@ Control.Slider.prototype = {
this.alignY = parseInt(this.options.alignY || '0');
this.trackLength = this.maximumOffset() - this.minimumOffset();
- this.handleLength = this.isVertical() ? this.handles[0].offsetHeight : this.handles[0].offsetWidth;
+
+ this.handleLength = this.isVertical() ?
+ (this.handles[0].offsetHeight != 0 ?
+ this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :
+ (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
+ this.handles[0].style.width.replace(/px$/,""));
this.active = false;
this.dragging = false;
@@ -137,8 +142,8 @@ Control.Slider.prototype = {
},
setValue: function(sliderValue, handleIdx){
if(!this.active) {
- this.activeHandle = this.handles[handleIdx];
- this.activeHandleIdx = handleIdx;
+ this.activeHandleIdx = handleIdx || 0;
+ this.activeHandle = this.handles[this.activeHandleIdx];
this.updateStyles();
}
handleIdx = handleIdx || this.activeHandleIdx || 0;
@@ -180,8 +185,11 @@ Control.Slider.prototype = {
return(this.isVertical() ? this.alignY : this.alignX);
},
maximumOffset: function(){
- return(this.isVertical() ?
- this.track.offsetHeight - this.alignY : this.track.offsetWidth - this.alignX);
+ return(this.isVertical() ?
+ (this.track.offsetHeight != 0 ? this.track.offsetHeight :
+ this.track.style.height.replace(/px$/,"")) - this.alignY :
+ (this.track.offsetWidth != 0 ? this.track.offsetWidth :
+ this.track.style.width.replace(/px$/,"")) - this.alignY);
},
isVertical: function(){
return (this.axis == 'vertical');
@@ -217,7 +225,8 @@ Control.Slider.prototype = {
var handle = Event.element(event);
var pointer = [Event.pointerX(event), Event.pointerY(event)];
- if(handle==this.track) {
+ var track = handle;
+ if(track==this.track) {
var offsets = Position.cumulativeOffset(this.track);
this.event = event;
this.setValue(this.translateToValue(