Ran "rake rails:update" to update resources to latest rails 1.2.3 ones.
This commit is contained in:
parent
57aeccccc8
commit
e8809a10f5
5 changed files with 1361 additions and 674 deletions
|
@ -3,7 +3,7 @@
|
||||||
unless defined?(RAILS_ROOT)
|
unless defined?(RAILS_ROOT)
|
||||||
root_path = File.join(File.dirname(__FILE__), '..')
|
root_path = File.join(File.dirname(__FILE__), '..')
|
||||||
|
|
||||||
unless RUBY_PLATFORM =~ /mswin32/
|
unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
root_path = Pathname.new(root_path).cleanpath(true).to_s
|
root_path = Pathname.new(root_path).cleanpath(true).to_s
|
||||||
end
|
end
|
||||||
|
@ -22,23 +22,24 @@ unless defined?(Rails::Initializer)
|
||||||
rails_gem_version = $1
|
rails_gem_version = $1
|
||||||
|
|
||||||
if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version
|
if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version
|
||||||
rails_gem = Gem.cache.search('rails', "=#{version}").first
|
# Asking for 1.1.6 will give you 1.1.6.5206, if available -- makes it easier to use beta gems
|
||||||
|
rails_gem = Gem.cache.search('rails', "~>#{version}.0").sort_by { |g| g.version.version }.last
|
||||||
|
|
||||||
if rails_gem
|
if rails_gem
|
||||||
require_gem "rails", "=#{version}"
|
gem "rails", "=#{rails_gem.version.version}"
|
||||||
require rails_gem.full_gem_path + '/lib/initializer'
|
require rails_gem.full_gem_path + '/lib/initializer'
|
||||||
else
|
else
|
||||||
STDERR.puts %(Cannot find gem for Rails =#{version}:
|
STDERR.puts %(Cannot find gem for Rails ~>#{version}.0:
|
||||||
Install the missing gem with 'gem install -v=#{version} rails', or
|
Install the missing gem with 'gem install -v=#{version} rails', or
|
||||||
change environment.rb to define RAILS_GEM_VERSION with your desired version.
|
change environment.rb to define RAILS_GEM_VERSION with your desired version.
|
||||||
)
|
)
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
require_gem "rails"
|
gem "rails"
|
||||||
require 'initializer'
|
require 'initializer'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Rails::Initializer.run(:set_load_path)
|
Rails::Initializer.run(:set_load_path)
|
||||||
end
|
end
|
||||||
|
|
64
public/javascripts/controls.js
vendored
64
public/javascripts/controls.js
vendored
|
@ -1,12 +1,13 @@
|
||||||
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
// (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
|
// (c) 2005, 2006 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
|
||||||
// (c) 2005 Jon Tirsen (http://www.tirsen.com)
|
// (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com)
|
||||||
// Contributors:
|
// Contributors:
|
||||||
// Richard Livsey
|
// Richard Livsey
|
||||||
// Rahul Bhargava
|
// Rahul Bhargava
|
||||||
// Rob Wills
|
// Rob Wills
|
||||||
//
|
//
|
||||||
// See scriptaculous.js for full license.
|
// script.aculo.us is freely distributable under the terms of an MIT-style license.
|
||||||
|
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
||||||
|
|
||||||
// Autocompleter.Base handles all the autocompletion functionality
|
// Autocompleter.Base handles all the autocompletion functionality
|
||||||
// that's independent of the data source for autocompletion. This
|
// that's independent of the data source for autocompletion. This
|
||||||
|
@ -33,6 +34,9 @@
|
||||||
// useful when one of the tokens is \n (a newline), as it
|
// useful when one of the tokens is \n (a newline), as it
|
||||||
// allows smart autocompletion after linebreaks.
|
// allows smart autocompletion after linebreaks.
|
||||||
|
|
||||||
|
if(typeof Effect == 'undefined')
|
||||||
|
throw("controls.js requires including script.aculo.us' effects.js library");
|
||||||
|
|
||||||
var Autocompleter = {}
|
var Autocompleter = {}
|
||||||
Autocompleter.Base = function() {};
|
Autocompleter.Base = function() {};
|
||||||
Autocompleter.Base.prototype = {
|
Autocompleter.Base.prototype = {
|
||||||
|
@ -45,7 +49,7 @@ Autocompleter.Base.prototype = {
|
||||||
this.index = 0;
|
this.index = 0;
|
||||||
this.entryCount = 0;
|
this.entryCount = 0;
|
||||||
|
|
||||||
if (this.setOptions)
|
if(this.setOptions)
|
||||||
this.setOptions(options);
|
this.setOptions(options);
|
||||||
else
|
else
|
||||||
this.options = options || {};
|
this.options = options || {};
|
||||||
|
@ -55,17 +59,20 @@ Autocompleter.Base.prototype = {
|
||||||
this.options.frequency = this.options.frequency || 0.4;
|
this.options.frequency = this.options.frequency || 0.4;
|
||||||
this.options.minChars = this.options.minChars || 1;
|
this.options.minChars = this.options.minChars || 1;
|
||||||
this.options.onShow = this.options.onShow ||
|
this.options.onShow = this.options.onShow ||
|
||||||
function(element, update){
|
function(element, update){
|
||||||
if(!update.style.position || update.style.position=='absolute') {
|
if(!update.style.position || update.style.position=='absolute') {
|
||||||
update.style.position = 'absolute';
|
update.style.position = 'absolute';
|
||||||
Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight});
|
Position.clone(element, update, {
|
||||||
}
|
setHeight: false,
|
||||||
Effect.Appear(update,{duration:0.15});
|
offsetTop: element.offsetHeight
|
||||||
};
|
});
|
||||||
|
}
|
||||||
|
Effect.Appear(update,{duration:0.15});
|
||||||
|
};
|
||||||
this.options.onHide = this.options.onHide ||
|
this.options.onHide = this.options.onHide ||
|
||||||
function(element, update){ new Effect.Fade(update,{duration:0.15}) };
|
function(element, update){ new Effect.Fade(update,{duration:0.15}) };
|
||||||
|
|
||||||
if (typeof(this.options.tokens) == 'string')
|
if(typeof(this.options.tokens) == 'string')
|
||||||
this.options.tokens = new Array(this.options.tokens);
|
this.options.tokens = new Array(this.options.tokens);
|
||||||
|
|
||||||
this.observer = null;
|
this.observer = null;
|
||||||
|
@ -94,7 +101,7 @@ Autocompleter.Base.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
fixIEOverlapping: function() {
|
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.iefix.style.zIndex = 1;
|
||||||
this.update.style.zIndex = 2;
|
this.update.style.zIndex = 2;
|
||||||
Element.show(this.iefix);
|
Element.show(this.iefix);
|
||||||
|
@ -202,11 +209,13 @@ Autocompleter.Base.prototype = {
|
||||||
markPrevious: function() {
|
markPrevious: function() {
|
||||||
if(this.index > 0) this.index--
|
if(this.index > 0) this.index--
|
||||||
else this.index = this.entryCount-1;
|
else this.index = this.entryCount-1;
|
||||||
|
this.getEntry(this.index).scrollIntoView(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
markNext: function() {
|
markNext: function() {
|
||||||
if(this.index < this.entryCount-1) this.index++
|
if(this.index < this.entryCount-1) this.index++
|
||||||
else this.index = 0;
|
else this.index = 0;
|
||||||
|
this.getEntry(this.index).scrollIntoView(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
getEntry: function(index) {
|
getEntry: function(index) {
|
||||||
|
@ -254,11 +263,11 @@ Autocompleter.Base.prototype = {
|
||||||
if(!this.changed && this.hasFocus) {
|
if(!this.changed && this.hasFocus) {
|
||||||
this.update.innerHTML = choices;
|
this.update.innerHTML = choices;
|
||||||
Element.cleanWhitespace(this.update);
|
Element.cleanWhitespace(this.update);
|
||||||
Element.cleanWhitespace(this.update.firstChild);
|
Element.cleanWhitespace(this.update.down());
|
||||||
|
|
||||||
if(this.update.firstChild && this.update.firstChild.childNodes) {
|
if(this.update.firstChild && this.update.down().childNodes) {
|
||||||
this.entryCount =
|
this.entryCount =
|
||||||
this.update.firstChild.childNodes.length;
|
this.update.down().childNodes.length;
|
||||||
for (var i = 0; i < this.entryCount; i++) {
|
for (var i = 0; i < this.entryCount; i++) {
|
||||||
var entry = this.getEntry(i);
|
var entry = this.getEntry(i);
|
||||||
entry.autocompleteIndex = i;
|
entry.autocompleteIndex = i;
|
||||||
|
@ -269,9 +278,14 @@ Autocompleter.Base.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.stopIndicator();
|
this.stopIndicator();
|
||||||
|
|
||||||
this.index = 0;
|
this.index = 0;
|
||||||
this.render();
|
|
||||||
|
if(this.entryCount==1 && this.options.autoSelect) {
|
||||||
|
this.selectEntry();
|
||||||
|
this.hide();
|
||||||
|
} else {
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -459,6 +473,7 @@ Ajax.InPlaceEditor.prototype = {
|
||||||
this.element = $(element);
|
this.element = $(element);
|
||||||
|
|
||||||
this.options = Object.extend({
|
this.options = Object.extend({
|
||||||
|
paramName: "value",
|
||||||
okButton: true,
|
okButton: true,
|
||||||
okText: "ok",
|
okText: "ok",
|
||||||
cancelLink: true,
|
cancelLink: true,
|
||||||
|
@ -531,7 +546,7 @@ Ajax.InPlaceEditor.prototype = {
|
||||||
Element.hide(this.element);
|
Element.hide(this.element);
|
||||||
this.createForm();
|
this.createForm();
|
||||||
this.element.parentNode.insertBefore(this.form, this.element);
|
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
|
// stop the event to avoid a page refresh in Safari
|
||||||
if (evt) {
|
if (evt) {
|
||||||
Event.stop(evt);
|
Event.stop(evt);
|
||||||
|
@ -590,7 +605,7 @@ Ajax.InPlaceEditor.prototype = {
|
||||||
var textField = document.createElement("input");
|
var textField = document.createElement("input");
|
||||||
textField.obj = this;
|
textField.obj = this;
|
||||||
textField.type = "text";
|
textField.type = "text";
|
||||||
textField.name = "value";
|
textField.name = this.options.paramName;
|
||||||
textField.value = text;
|
textField.value = text;
|
||||||
textField.style.backgroundColor = this.options.highlightcolor;
|
textField.style.backgroundColor = this.options.highlightcolor;
|
||||||
textField.className = 'editor_field';
|
textField.className = 'editor_field';
|
||||||
|
@ -603,7 +618,7 @@ Ajax.InPlaceEditor.prototype = {
|
||||||
this.options.textarea = true;
|
this.options.textarea = true;
|
||||||
var textArea = document.createElement("textarea");
|
var textArea = document.createElement("textarea");
|
||||||
textArea.obj = this;
|
textArea.obj = this;
|
||||||
textArea.name = "value";
|
textArea.name = this.options.paramName;
|
||||||
textArea.value = this.convertHTMLLineBreaks(text);
|
textArea.value = this.convertHTMLLineBreaks(text);
|
||||||
textArea.rows = this.options.rows;
|
textArea.rows = this.options.rows;
|
||||||
textArea.cols = this.options.cols || 40;
|
textArea.cols = this.options.cols || 40;
|
||||||
|
@ -636,6 +651,7 @@ Ajax.InPlaceEditor.prototype = {
|
||||||
Element.removeClassName(this.form, this.options.loadingClassName);
|
Element.removeClassName(this.form, this.options.loadingClassName);
|
||||||
this.editField.disabled = false;
|
this.editField.disabled = false;
|
||||||
this.editField.value = transport.responseText.stripTags();
|
this.editField.value = transport.responseText.stripTags();
|
||||||
|
Field.scrollFreeActivate(this.editField);
|
||||||
},
|
},
|
||||||
onclickCancel: function() {
|
onclickCancel: function() {
|
||||||
this.onComplete();
|
this.onComplete();
|
||||||
|
@ -772,6 +788,8 @@ Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
|
||||||
collection.each(function(e,i) {
|
collection.each(function(e,i) {
|
||||||
optionTag = document.createElement("option");
|
optionTag = document.createElement("option");
|
||||||
optionTag.value = (e instanceof Array) ? e[0] : e;
|
optionTag.value = (e instanceof Array) ? e[0] : e;
|
||||||
|
if((typeof this.options.value == 'undefined') &&
|
||||||
|
((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true;
|
||||||
if(this.options.value==optionTag.value) optionTag.selected = true;
|
if(this.options.value==optionTag.value) optionTag.selected = true;
|
||||||
optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e));
|
optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e));
|
||||||
selectTag.appendChild(optionTag);
|
selectTag.appendChild(optionTag);
|
||||||
|
|
181
public/javascripts/dragdrop.js
vendored
181
public/javascripts/dragdrop.js
vendored
|
@ -1,9 +1,11 @@
|
||||||
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
// (c) 2005 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
|
// (c) 2005, 2006 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
|
||||||
//
|
//
|
||||||
// See scriptaculous.js for full license.
|
// script.aculo.us is freely distributable under the terms of an MIT-style license.
|
||||||
|
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
if(typeof Effect == 'undefined')
|
||||||
|
throw("dragdrop.js requires including script.aculo.us' effects.js library");
|
||||||
|
|
||||||
var Droppables = {
|
var Droppables = {
|
||||||
drops: [],
|
drops: [],
|
||||||
|
@ -145,8 +147,16 @@ var Draggables = {
|
||||||
},
|
},
|
||||||
|
|
||||||
activate: function(draggable) {
|
activate: function(draggable) {
|
||||||
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
|
if(draggable.options.delay) {
|
||||||
this.activeDraggable = draggable;
|
this._timeout = setTimeout(function() {
|
||||||
|
Draggables._timeout = null;
|
||||||
|
window.focus();
|
||||||
|
Draggables.activeDraggable = draggable;
|
||||||
|
}.bind(this), draggable.options.delay);
|
||||||
|
} else {
|
||||||
|
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
|
||||||
|
this.activeDraggable = draggable;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivate: function() {
|
deactivate: function() {
|
||||||
|
@ -160,10 +170,15 @@ var Draggables = {
|
||||||
// the same coordinates, prevent needless redrawing (moz bug?)
|
// the same coordinates, prevent needless redrawing (moz bug?)
|
||||||
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
|
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
|
||||||
this._lastPointer = pointer;
|
this._lastPointer = pointer;
|
||||||
|
|
||||||
this.activeDraggable.updateDrag(event, pointer);
|
this.activeDraggable.updateDrag(event, pointer);
|
||||||
},
|
},
|
||||||
|
|
||||||
endDrag: function(event) {
|
endDrag: function(event) {
|
||||||
|
if(this._timeout) {
|
||||||
|
clearTimeout(this._timeout);
|
||||||
|
this._timeout = null;
|
||||||
|
}
|
||||||
if(!this.activeDraggable) return;
|
if(!this.activeDraggable) return;
|
||||||
this._lastPointer = null;
|
this._lastPointer = null;
|
||||||
this.activeDraggable.endDrag(event);
|
this.activeDraggable.endDrag(event);
|
||||||
|
@ -190,6 +205,7 @@ var Draggables = {
|
||||||
this.observers.each( function(o) {
|
this.observers.each( function(o) {
|
||||||
if(o[eventName]) o[eventName](eventName, draggable, event);
|
if(o[eventName]) o[eventName](eventName, draggable, event);
|
||||||
});
|
});
|
||||||
|
if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
|
||||||
},
|
},
|
||||||
|
|
||||||
_cacheObserverCallbacks: function() {
|
_cacheObserverCallbacks: function() {
|
||||||
|
@ -204,39 +220,59 @@ var Draggables = {
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
var Draggable = Class.create();
|
var Draggable = Class.create();
|
||||||
|
Draggable._dragging = {};
|
||||||
|
|
||||||
Draggable.prototype = {
|
Draggable.prototype = {
|
||||||
initialize: function(element) {
|
initialize: function(element) {
|
||||||
var options = Object.extend({
|
var defaults = {
|
||||||
handle: false,
|
handle: false,
|
||||||
starteffect: function(element) {
|
|
||||||
new Effect.Opacity(element, {duration:0.2, from:1.0, to:0.7});
|
|
||||||
},
|
|
||||||
reverteffect: function(element, top_offset, left_offset) {
|
reverteffect: function(element, top_offset, left_offset) {
|
||||||
var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
|
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});
|
new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur,
|
||||||
|
queue: {scope:'_draggable', position:'end'}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
endeffect: function(element) {
|
endeffect: function(element) {
|
||||||
new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0});
|
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,
|
zindex: 1000,
|
||||||
revert: false,
|
revert: false,
|
||||||
scroll: false,
|
scroll: false,
|
||||||
scrollSensitivity: 20,
|
scrollSensitivity: 20,
|
||||||
scrollSpeed: 15,
|
scrollSpeed: 15,
|
||||||
snap: false // false, or xy or [x,y] or function(x,y){ return [x,y] }
|
snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
|
||||||
}, arguments[1] || {});
|
delay: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
if(!arguments[1] || typeof arguments[1].endeffect == 'undefined')
|
||||||
|
Object.extend(defaults, {
|
||||||
|
starteffect: function(element) {
|
||||||
|
element._opacity = Element.getOpacity(element);
|
||||||
|
Draggable._dragging[element] = true;
|
||||||
|
new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var options = Object.extend(defaults, arguments[1] || {});
|
||||||
|
|
||||||
this.element = $(element);
|
this.element = $(element);
|
||||||
|
|
||||||
if(options.handle && (typeof options.handle == 'string')) {
|
if(options.handle && (typeof options.handle == 'string'))
|
||||||
var h = Element.childrenWithClassName(this.element, options.handle, true);
|
this.handle = this.element.down('.'+options.handle, 0);
|
||||||
if(h.length>0) this.handle = h[0];
|
|
||||||
}
|
|
||||||
if(!this.handle) this.handle = $(options.handle);
|
if(!this.handle) this.handle = $(options.handle);
|
||||||
if(!this.handle) this.handle = this.element;
|
if(!this.handle) this.handle = this.element;
|
||||||
|
|
||||||
if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML)
|
if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
|
||||||
options.scroll = $(options.scroll);
|
options.scroll = $(options.scroll);
|
||||||
|
this._isScrollChild = Element.childOf(this.element, options.scroll);
|
||||||
|
}
|
||||||
|
|
||||||
Element.makePositioned(this.element); // fix IE
|
Element.makePositioned(this.element); // fix IE
|
||||||
|
|
||||||
|
@ -262,6 +298,8 @@ Draggable.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
initDrag: function(event) {
|
initDrag: function(event) {
|
||||||
|
if(typeof Draggable._dragging[this.element] != 'undefined' &&
|
||||||
|
Draggable._dragging[this.element]) return;
|
||||||
if(Event.isLeftClick(event)) {
|
if(Event.isLeftClick(event)) {
|
||||||
// abort on form elements, fixes a Firefox issue
|
// abort on form elements, fixes a Firefox issue
|
||||||
var src = Event.element(event);
|
var src = Event.element(event);
|
||||||
|
@ -272,11 +310,6 @@ Draggable.prototype = {
|
||||||
src.tagName=='BUTTON' ||
|
src.tagName=='BUTTON' ||
|
||||||
src.tagName=='TEXTAREA')) return;
|
src.tagName=='TEXTAREA')) return;
|
||||||
|
|
||||||
if(this.element._revert) {
|
|
||||||
this.element._revert.cancel();
|
|
||||||
this.element._revert = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
||||||
var pos = Position.cumulativeOffset(this.element);
|
var pos = Position.cumulativeOffset(this.element);
|
||||||
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
|
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
|
||||||
|
@ -312,6 +345,7 @@ Draggable.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
Draggables.notify('onStart', this, event);
|
Draggables.notify('onStart', this, event);
|
||||||
|
|
||||||
if(this.options.starteffect) this.options.starteffect(this.element);
|
if(this.options.starteffect) this.options.starteffect(this.element);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -320,6 +354,7 @@ Draggable.prototype = {
|
||||||
Position.prepare();
|
Position.prepare();
|
||||||
Droppables.show(pointer, this.element);
|
Droppables.show(pointer, this.element);
|
||||||
Draggables.notify('onDrag', this, event);
|
Draggables.notify('onDrag', this, event);
|
||||||
|
|
||||||
this.draw(pointer);
|
this.draw(pointer);
|
||||||
if(this.options.change) this.options.change(this);
|
if(this.options.change) this.options.change(this);
|
||||||
|
|
||||||
|
@ -331,8 +366,8 @@ Draggable.prototype = {
|
||||||
with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
|
with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
|
||||||
} else {
|
} else {
|
||||||
p = Position.page(this.options.scroll);
|
p = Position.page(this.options.scroll);
|
||||||
p[0] += this.options.scroll.scrollLeft;
|
p[0] += this.options.scroll.scrollLeft + Position.deltaX;
|
||||||
p[1] += this.options.scroll.scrollTop;
|
p[1] += this.options.scroll.scrollTop + Position.deltaY;
|
||||||
p.push(p[0]+this.options.scroll.offsetWidth);
|
p.push(p[0]+this.options.scroll.offsetWidth);
|
||||||
p.push(p[1]+this.options.scroll.offsetHeight);
|
p.push(p[1]+this.options.scroll.offsetHeight);
|
||||||
}
|
}
|
||||||
|
@ -378,7 +413,7 @@ Draggable.prototype = {
|
||||||
|
|
||||||
if(this.options.endeffect)
|
if(this.options.endeffect)
|
||||||
this.options.endeffect(this.element);
|
this.options.endeffect(this.element);
|
||||||
|
|
||||||
Draggables.deactivate(this);
|
Draggables.deactivate(this);
|
||||||
Droppables.reset();
|
Droppables.reset();
|
||||||
},
|
},
|
||||||
|
@ -398,10 +433,15 @@ Draggable.prototype = {
|
||||||
|
|
||||||
draw: function(point) {
|
draw: function(point) {
|
||||||
var pos = Position.cumulativeOffset(this.element);
|
var pos = Position.cumulativeOffset(this.element);
|
||||||
|
if(this.options.ghosting) {
|
||||||
|
var r = Position.realOffset(this.element);
|
||||||
|
pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
|
||||||
|
}
|
||||||
|
|
||||||
var d = this.currentDelta();
|
var d = this.currentDelta();
|
||||||
pos[0] -= d[0]; pos[1] -= d[1];
|
pos[0] -= d[0]; pos[1] -= d[1];
|
||||||
|
|
||||||
if(this.options.scroll && (this.options.scroll != window)) {
|
if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
|
||||||
pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
|
pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
|
||||||
pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
|
pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
|
||||||
}
|
}
|
||||||
|
@ -412,7 +452,7 @@ Draggable.prototype = {
|
||||||
|
|
||||||
if(this.options.snap) {
|
if(this.options.snap) {
|
||||||
if(typeof this.options.snap == 'function') {
|
if(typeof this.options.snap == 'function') {
|
||||||
p = this.options.snap(p[0],p[1]);
|
p = this.options.snap(p[0],p[1],this);
|
||||||
} else {
|
} else {
|
||||||
if(this.options.snap instanceof Array) {
|
if(this.options.snap instanceof Array) {
|
||||||
p = p.map( function(v, i) {
|
p = p.map( function(v, i) {
|
||||||
|
@ -428,6 +468,7 @@ Draggable.prototype = {
|
||||||
style.left = p[0] + "px";
|
style.left = p[0] + "px";
|
||||||
if((!this.options.constraint) || (this.options.constraint=='vertical'))
|
if((!this.options.constraint) || (this.options.constraint=='vertical'))
|
||||||
style.top = p[1] + "px";
|
style.top = p[1] + "px";
|
||||||
|
|
||||||
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
|
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -440,6 +481,7 @@ Draggable.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
startScrolling: function(speed) {
|
startScrolling: function(speed) {
|
||||||
|
if(!(speed[0] || speed[1])) return;
|
||||||
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
|
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
|
||||||
this.lastScrolled = new Date();
|
this.lastScrolled = new Date();
|
||||||
this.scrollInterval = setInterval(this.scroll.bind(this), 10);
|
this.scrollInterval = setInterval(this.scroll.bind(this), 10);
|
||||||
|
@ -464,14 +506,16 @@ Draggable.prototype = {
|
||||||
Position.prepare();
|
Position.prepare();
|
||||||
Droppables.show(Draggables._lastPointer, this.element);
|
Droppables.show(Draggables._lastPointer, this.element);
|
||||||
Draggables.notify('onDrag', this);
|
Draggables.notify('onDrag', this);
|
||||||
Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer);
|
if (this._isScrollChild) {
|
||||||
Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000;
|
Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer);
|
||||||
Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000;
|
Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000;
|
||||||
if (Draggables._lastScrollPointer[0] < 0)
|
Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000;
|
||||||
Draggables._lastScrollPointer[0] = 0;
|
if (Draggables._lastScrollPointer[0] < 0)
|
||||||
if (Draggables._lastScrollPointer[1] < 0)
|
Draggables._lastScrollPointer[0] = 0;
|
||||||
Draggables._lastScrollPointer[1] = 0;
|
if (Draggables._lastScrollPointer[1] < 0)
|
||||||
this.draw(Draggables._lastScrollPointer);
|
Draggables._lastScrollPointer[1] = 0;
|
||||||
|
this.draw(Draggables._lastScrollPointer);
|
||||||
|
}
|
||||||
|
|
||||||
if(this.options.change) this.options.change(this);
|
if(this.options.change) this.options.change(this);
|
||||||
},
|
},
|
||||||
|
@ -523,6 +567,8 @@ SortableObserver.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var Sortable = {
|
var Sortable = {
|
||||||
|
SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
|
||||||
|
|
||||||
sortables: {},
|
sortables: {},
|
||||||
|
|
||||||
_findRootElement: function(element) {
|
_findRootElement: function(element) {
|
||||||
|
@ -563,12 +609,13 @@ var Sortable = {
|
||||||
containment: element, // also takes array of elements (or id's); or false
|
containment: element, // also takes array of elements (or id's); or false
|
||||||
handle: false, // or a CSS class
|
handle: false, // or a CSS class
|
||||||
only: false,
|
only: false,
|
||||||
|
delay: 0,
|
||||||
hoverclass: null,
|
hoverclass: null,
|
||||||
ghosting: false,
|
ghosting: false,
|
||||||
scroll: false,
|
scroll: false,
|
||||||
scrollSensitivity: 20,
|
scrollSensitivity: 20,
|
||||||
scrollSpeed: 15,
|
scrollSpeed: 15,
|
||||||
format: /^[^_]*_(.*)$/,
|
format: this.SERIALIZE_RULE,
|
||||||
onChange: Prototype.emptyFunction,
|
onChange: Prototype.emptyFunction,
|
||||||
onUpdate: Prototype.emptyFunction
|
onUpdate: Prototype.emptyFunction
|
||||||
}, arguments[1] || {});
|
}, arguments[1] || {});
|
||||||
|
@ -582,6 +629,7 @@ var Sortable = {
|
||||||
scroll: options.scroll,
|
scroll: options.scroll,
|
||||||
scrollSpeed: options.scrollSpeed,
|
scrollSpeed: options.scrollSpeed,
|
||||||
scrollSensitivity: options.scrollSensitivity,
|
scrollSensitivity: options.scrollSensitivity,
|
||||||
|
delay: options.delay,
|
||||||
ghosting: options.ghosting,
|
ghosting: options.ghosting,
|
||||||
constraint: options.constraint,
|
constraint: options.constraint,
|
||||||
handle: options.handle };
|
handle: options.handle };
|
||||||
|
@ -610,7 +658,6 @@ var Sortable = {
|
||||||
tree: options.tree,
|
tree: options.tree,
|
||||||
hoverclass: options.hoverclass,
|
hoverclass: options.hoverclass,
|
||||||
onHover: Sortable.onHover
|
onHover: Sortable.onHover
|
||||||
//greedy: !options.dropOnEmpty
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var options_for_tree = {
|
var options_for_tree = {
|
||||||
|
@ -635,7 +682,7 @@ var Sortable = {
|
||||||
(this.findElements(element, options) || []).each( function(e) {
|
(this.findElements(element, options) || []).each( function(e) {
|
||||||
// handles are per-draggable
|
// handles are per-draggable
|
||||||
var handle = options.handle ?
|
var handle = options.handle ?
|
||||||
Element.childrenWithClassName(e, options.handle)[0] : e;
|
$(e).down('.'+options.handle,0) : e;
|
||||||
options.draggables.push(
|
options.draggables.push(
|
||||||
new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
|
new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
|
||||||
Droppables.add(e, options_for_droppable);
|
Droppables.add(e, options_for_droppable);
|
||||||
|
@ -706,7 +753,7 @@ var Sortable = {
|
||||||
if(!Element.isParent(dropon, element)) {
|
if(!Element.isParent(dropon, element)) {
|
||||||
var index;
|
var index;
|
||||||
|
|
||||||
var children = Sortable.findElements(dropon, {tag: droponOptions.tag});
|
var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
|
||||||
var child = null;
|
var child = null;
|
||||||
|
|
||||||
if(children) {
|
if(children) {
|
||||||
|
@ -733,7 +780,7 @@ var Sortable = {
|
||||||
},
|
},
|
||||||
|
|
||||||
unmark: function() {
|
unmark: function() {
|
||||||
if(Sortable._marker) Element.hide(Sortable._marker);
|
if(Sortable._marker) Sortable._marker.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
mark: function(dropon, position) {
|
mark: function(dropon, position) {
|
||||||
|
@ -742,23 +789,21 @@ var Sortable = {
|
||||||
if(sortable && !sortable.ghosting) return;
|
if(sortable && !sortable.ghosting) return;
|
||||||
|
|
||||||
if(!Sortable._marker) {
|
if(!Sortable._marker) {
|
||||||
Sortable._marker = $('dropmarker') || document.createElement('DIV');
|
Sortable._marker =
|
||||||
Element.hide(Sortable._marker);
|
($('dropmarker') || Element.extend(document.createElement('DIV'))).
|
||||||
Element.addClassName(Sortable._marker, 'dropmarker');
|
hide().addClassName('dropmarker').setStyle({position:'absolute'});
|
||||||
Sortable._marker.style.position = 'absolute';
|
|
||||||
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
|
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
|
||||||
}
|
}
|
||||||
var offsets = Position.cumulativeOffset(dropon);
|
var offsets = Position.cumulativeOffset(dropon);
|
||||||
Sortable._marker.style.left = offsets[0] + 'px';
|
Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
|
||||||
Sortable._marker.style.top = offsets[1] + 'px';
|
|
||||||
|
|
||||||
if(position=='after')
|
if(position=='after')
|
||||||
if(sortable.overlap == 'horizontal')
|
if(sortable.overlap == 'horizontal')
|
||||||
Sortable._marker.style.left = (offsets[0]+dropon.clientWidth) + 'px';
|
Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'});
|
||||||
else
|
else
|
||||||
Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px';
|
Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'});
|
||||||
|
|
||||||
Element.show(Sortable._marker);
|
Sortable._marker.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
_tree: function(element, options, parent) {
|
_tree: function(element, options, parent) {
|
||||||
|
@ -773,9 +818,9 @@ var Sortable = {
|
||||||
id: encodeURIComponent(match ? match[1] : null),
|
id: encodeURIComponent(match ? match[1] : null),
|
||||||
element: element,
|
element: element,
|
||||||
parent: parent,
|
parent: parent,
|
||||||
children: new Array,
|
children: [],
|
||||||
position: parent.children.length,
|
position: parent.children.length,
|
||||||
container: Sortable._findChildrenElement(children[i], options.treeTag.toUpperCase())
|
container: $(children[i]).down(options.treeTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the element containing the children and recurse over it */
|
/* Get the element containing the children and recurse over it */
|
||||||
|
@ -788,17 +833,6 @@ var Sortable = {
|
||||||
return parent;
|
return parent;
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Finds the first element of the given tag type within a parent element.
|
|
||||||
Used for finding the first LI[ST] within a L[IST]I[TEM].*/
|
|
||||||
_findChildrenElement: function (element, containerTag) {
|
|
||||||
if (element && element.hasChildNodes)
|
|
||||||
for (var i = 0; i < element.childNodes.length; ++i)
|
|
||||||
if (element.childNodes[i].tagName == containerTag)
|
|
||||||
return element.childNodes[i];
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
|
|
||||||
tree: function(element) {
|
tree: function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
var sortableOptions = this.options(element);
|
var sortableOptions = this.options(element);
|
||||||
|
@ -813,12 +847,12 @@ var Sortable = {
|
||||||
var root = {
|
var root = {
|
||||||
id: null,
|
id: null,
|
||||||
parent: null,
|
parent: null,
|
||||||
children: new Array,
|
children: [],
|
||||||
container: element,
|
container: element,
|
||||||
position: 0
|
position: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return Sortable._tree (element, options, root);
|
return Sortable._tree(element, options, root);
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Construct a [i] index for a particular node */
|
/* Construct a [i] index for a particular node */
|
||||||
|
@ -867,7 +901,7 @@ var Sortable = {
|
||||||
|
|
||||||
if (options.tree) {
|
if (options.tree) {
|
||||||
return Sortable.tree(element, arguments[1]).children.map( function (item) {
|
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));
|
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
|
||||||
}).flatten().join('&');
|
}).flatten().join('&');
|
||||||
} else {
|
} else {
|
||||||
|
@ -878,12 +912,10 @@ var Sortable = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns true if child is contained within element */
|
// Returns true if child is contained within element
|
||||||
Element.isParent = function(child, element) {
|
Element.isParent = function(child, element) {
|
||||||
if (!child.parentNode || child == element) return false;
|
if (!child.parentNode || child == element) return false;
|
||||||
|
|
||||||
if (child.parentNode == element) return true;
|
if (child.parentNode == element) return true;
|
||||||
|
|
||||||
return Element.isParent(child.parentNode, element);
|
return Element.isParent(child.parentNode, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -906,8 +938,5 @@ Element.findChildren = function(element, only, recursive, tagName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Element.offsetSize = function (element, type) {
|
Element.offsetSize = function (element, type) {
|
||||||
if (type == 'vertical' || type == 'height')
|
return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
|
||||||
return element.offsetHeight;
|
}
|
||||||
else
|
|
||||||
return element.offsetWidth;
|
|
||||||
}
|
|
||||||
|
|
456
public/javascripts/effects.js
vendored
456
public/javascripts/effects.js
vendored
|
@ -1,15 +1,16 @@
|
||||||
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
// Contributors:
|
// Contributors:
|
||||||
// Justin Palmer (http://encytemedia.com/)
|
// Justin Palmer (http://encytemedia.com/)
|
||||||
// Mark Pilgrim (http://diveintomark.org/)
|
// Mark Pilgrim (http://diveintomark.org/)
|
||||||
// Martin Bialasinki
|
// Martin Bialasinki
|
||||||
//
|
//
|
||||||
// See scriptaculous.js for full license.
|
// script.aculo.us is freely distributable under the terms of an MIT-style license.
|
||||||
|
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
||||||
|
|
||||||
// converts rgb() and #xxx to #xxxxxx format,
|
// converts rgb() and #xxx to #xxxxxx format,
|
||||||
// returns self (or first argument) if not convertable
|
// returns self (or first argument) if not convertable
|
||||||
String.prototype.parseColor = function() {
|
String.prototype.parseColor = function() {
|
||||||
var color = '#';
|
var color = '#';
|
||||||
if(this.slice(0,4) == 'rgb(') {
|
if(this.slice(0,4) == 'rgb(') {
|
||||||
var cols = this.slice(4,this.length-1).split(',');
|
var cols = this.slice(4,this.length-1).split(',');
|
||||||
var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
|
var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
|
||||||
|
@ -41,15 +42,17 @@ Element.collectTextNodesIgnoreClass = function(element, className) {
|
||||||
|
|
||||||
Element.setContentZoom = function(element, percent) {
|
Element.setContentZoom = function(element, percent) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
Element.setStyle(element, {fontSize: (percent/100) + 'em'});
|
element.setStyle({fontSize: (percent/100) + 'em'});
|
||||||
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
|
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element.getOpacity = function(element){
|
Element.getOpacity = function(element){
|
||||||
|
element = $(element);
|
||||||
var opacity;
|
var opacity;
|
||||||
if (opacity = Element.getStyle(element, 'opacity'))
|
if (opacity = element.getStyle('opacity'))
|
||||||
return parseFloat(opacity);
|
return parseFloat(opacity);
|
||||||
if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/))
|
if (opacity = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
|
||||||
if(opacity[1]) return parseFloat(opacity[1]) / 100;
|
if(opacity[1]) return parseFloat(opacity[1]) / 100;
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
@ -57,34 +60,26 @@ Element.getOpacity = function(element){
|
||||||
Element.setOpacity = function(element, value){
|
Element.setOpacity = function(element, value){
|
||||||
element= $(element);
|
element= $(element);
|
||||||
if (value == 1){
|
if (value == 1){
|
||||||
Element.setStyle(element, { opacity:
|
element.setStyle({ opacity:
|
||||||
(/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ?
|
(/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ?
|
||||||
0.999999 : null });
|
0.999999 : 1.0 });
|
||||||
if(/MSIE/.test(navigator.userAgent))
|
if(/MSIE/.test(navigator.userAgent) && !window.opera)
|
||||||
Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});
|
element.setStyle({filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});
|
||||||
} else {
|
} else {
|
||||||
if(value < 0.00001) value = 0;
|
if(value < 0.00001) value = 0;
|
||||||
Element.setStyle(element, {opacity: value});
|
element.setStyle({opacity: value});
|
||||||
if(/MSIE/.test(navigator.userAgent))
|
if(/MSIE/.test(navigator.userAgent) && !window.opera)
|
||||||
Element.setStyle(element,
|
element.setStyle(
|
||||||
{ filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
|
{ filter: element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') +
|
||||||
'alpha(opacity='+value*100+')' });
|
'alpha(opacity='+value*100+')' });
|
||||||
}
|
}
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element.getInlineOpacity = function(element){
|
Element.getInlineOpacity = function(element){
|
||||||
return $(element).style.opacity || '';
|
return $(element).style.opacity || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
Element.childrenWithClassName = function(element, className, findFirst) {
|
|
||||||
var classNameRegExp = new RegExp("(^|\\s)" + className + "(\\s|$)");
|
|
||||||
var results = $A($(element).getElementsByTagName('*'))[findFirst ? 'detect' : 'select']( function(c) {
|
|
||||||
return (c.className && c.className.match(classNameRegExp));
|
|
||||||
});
|
|
||||||
if(!results) results = [];
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
Element.forceRerendering = function(element) {
|
Element.forceRerendering = function(element) {
|
||||||
try {
|
try {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
|
@ -104,9 +99,17 @@ Array.prototype.call = function() {
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
var Effect = {
|
var Effect = {
|
||||||
|
_elementDoesNotExistError: {
|
||||||
|
name: 'ElementDoesNotExistError',
|
||||||
|
message: 'The specified DOM element does not exist, but is required for this effect to operate'
|
||||||
|
},
|
||||||
tagifyText: function(element) {
|
tagifyText: function(element) {
|
||||||
|
if(typeof Builder == 'undefined')
|
||||||
|
throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
|
||||||
|
|
||||||
var tagifyStyle = 'position:relative';
|
var tagifyStyle = 'position:relative';
|
||||||
if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1';
|
if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1';
|
||||||
|
|
||||||
element = $(element);
|
element = $(element);
|
||||||
$A(element.childNodes).each( function(child) {
|
$A(element.childNodes).each( function(child) {
|
||||||
if(child.nodeType==3) {
|
if(child.nodeType==3) {
|
||||||
|
@ -159,33 +162,35 @@ var Effect2 = Effect; // deprecated
|
||||||
|
|
||||||
/* ------------- transitions ------------- */
|
/* ------------- transitions ------------- */
|
||||||
|
|
||||||
Effect.Transitions = {}
|
Effect.Transitions = {
|
||||||
|
linear: Prototype.K,
|
||||||
Effect.Transitions.linear = function(pos) {
|
sinoidal: function(pos) {
|
||||||
return pos;
|
return (-Math.cos(pos*Math.PI)/2) + 0.5;
|
||||||
}
|
},
|
||||||
Effect.Transitions.sinoidal = function(pos) {
|
reverse: function(pos) {
|
||||||
return (-Math.cos(pos*Math.PI)/2) + 0.5;
|
return 1-pos;
|
||||||
}
|
},
|
||||||
Effect.Transitions.reverse = function(pos) {
|
flicker: function(pos) {
|
||||||
return 1-pos;
|
return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
|
||||||
}
|
},
|
||||||
Effect.Transitions.flicker = function(pos) {
|
wobble: function(pos) {
|
||||||
return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
|
return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
|
||||||
}
|
},
|
||||||
Effect.Transitions.wobble = function(pos) {
|
pulse: function(pos, pulses) {
|
||||||
return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
|
pulses = pulses || 5;
|
||||||
}
|
return (
|
||||||
Effect.Transitions.pulse = function(pos) {
|
Math.round((pos % (1/pulses)) * pulses) == 0 ?
|
||||||
return (Math.floor(pos*10) % 2 == 0 ?
|
((pos * pulses * 2) - Math.floor(pos * pulses * 2)) :
|
||||||
(pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10)));
|
1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2))
|
||||||
}
|
);
|
||||||
Effect.Transitions.none = function(pos) {
|
},
|
||||||
return 0;
|
none: function(pos) {
|
||||||
}
|
return 0;
|
||||||
Effect.Transitions.full = function(pos) {
|
},
|
||||||
return 1;
|
full: function(pos) {
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* ------------- core effects ------------- */
|
/* ------------- core effects ------------- */
|
||||||
|
|
||||||
|
@ -212,6 +217,9 @@ Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
|
||||||
e.finishOn += effect.finishOn;
|
e.finishOn += effect.finishOn;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case 'with-last':
|
||||||
|
timestamp = this.effects.pluck('startOn').max() || timestamp;
|
||||||
|
break;
|
||||||
case 'end':
|
case 'end':
|
||||||
// start effect after last queued effect has finished
|
// start effect after last queued effect has finished
|
||||||
timestamp = this.effects.pluck('finishOn').max() || timestamp;
|
timestamp = this.effects.pluck('finishOn').max() || timestamp;
|
||||||
|
@ -348,12 +356,24 @@ Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Effect.Event = Class.create();
|
||||||
|
Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), {
|
||||||
|
initialize: function() {
|
||||||
|
var options = Object.extend({
|
||||||
|
duration: 0
|
||||||
|
}, arguments[0] || {});
|
||||||
|
this.start(options);
|
||||||
|
},
|
||||||
|
update: Prototype.emptyFunction
|
||||||
|
});
|
||||||
|
|
||||||
Effect.Opacity = Class.create();
|
Effect.Opacity = Class.create();
|
||||||
Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
|
Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
|
||||||
initialize: function(element) {
|
initialize: function(element) {
|
||||||
this.element = $(element);
|
this.element = $(element);
|
||||||
|
if(!this.element) throw(Effect._elementDoesNotExistError);
|
||||||
// make this work on IE on elements without 'layout'
|
// make this work on IE on elements without 'layout'
|
||||||
if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
|
if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout))
|
||||||
this.element.setStyle({zoom: 1});
|
this.element.setStyle({zoom: 1});
|
||||||
var options = Object.extend({
|
var options = Object.extend({
|
||||||
from: this.element.getOpacity() || 0.0,
|
from: this.element.getOpacity() || 0.0,
|
||||||
|
@ -370,6 +390,7 @@ Effect.Move = Class.create();
|
||||||
Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
|
Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
|
||||||
initialize: function(element) {
|
initialize: function(element) {
|
||||||
this.element = $(element);
|
this.element = $(element);
|
||||||
|
if(!this.element) throw(Effect._elementDoesNotExistError);
|
||||||
var options = Object.extend({
|
var options = Object.extend({
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
|
@ -393,8 +414,8 @@ Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
|
||||||
},
|
},
|
||||||
update: function(position) {
|
update: function(position) {
|
||||||
this.element.setStyle({
|
this.element.setStyle({
|
||||||
left: this.options.x * position + this.originalLeft + 'px',
|
left: Math.round(this.options.x * position + this.originalLeft) + 'px',
|
||||||
top: this.options.y * position + this.originalTop + 'px'
|
top: Math.round(this.options.y * position + this.originalTop) + 'px'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -408,7 +429,8 @@ Effect.MoveBy = function(element, toTop, toLeft) {
|
||||||
Effect.Scale = Class.create();
|
Effect.Scale = Class.create();
|
||||||
Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
|
Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
|
||||||
initialize: function(element, percent) {
|
initialize: function(element, percent) {
|
||||||
this.element = $(element)
|
this.element = $(element);
|
||||||
|
if(!this.element) throw(Effect._elementDoesNotExistError);
|
||||||
var options = Object.extend({
|
var options = Object.extend({
|
||||||
scaleX: true,
|
scaleX: true,
|
||||||
scaleY: true,
|
scaleY: true,
|
||||||
|
@ -433,7 +455,7 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
|
||||||
this.originalLeft = this.element.offsetLeft;
|
this.originalLeft = this.element.offsetLeft;
|
||||||
|
|
||||||
var fontSize = this.element.getStyle('font-size') || '100%';
|
var fontSize = this.element.getStyle('font-size') || '100%';
|
||||||
['em','px','%'].each( function(fontSizeType) {
|
['em','px','%','pt'].each( function(fontSizeType) {
|
||||||
if(fontSize.indexOf(fontSizeType)>0) {
|
if(fontSize.indexOf(fontSizeType)>0) {
|
||||||
this.fontSize = parseFloat(fontSize);
|
this.fontSize = parseFloat(fontSize);
|
||||||
this.fontSizeType = fontSizeType;
|
this.fontSizeType = fontSizeType;
|
||||||
|
@ -458,12 +480,12 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
|
||||||
this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
|
this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
|
||||||
},
|
},
|
||||||
finish: function(position) {
|
finish: function(position) {
|
||||||
if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
|
if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
|
||||||
},
|
},
|
||||||
setDimensions: function(height, width) {
|
setDimensions: function(height, width) {
|
||||||
var d = {};
|
var d = {};
|
||||||
if(this.options.scaleX) d.width = width + 'px';
|
if(this.options.scaleX) d.width = Math.round(width) + 'px';
|
||||||
if(this.options.scaleY) d.height = height + 'px';
|
if(this.options.scaleY) d.height = Math.round(height) + 'px';
|
||||||
if(this.options.scaleFromCenter) {
|
if(this.options.scaleFromCenter) {
|
||||||
var topd = (height - this.dims[0])/2;
|
var topd = (height - this.dims[0])/2;
|
||||||
var leftd = (width - this.dims[1])/2;
|
var leftd = (width - this.dims[1])/2;
|
||||||
|
@ -483,6 +505,7 @@ Effect.Highlight = Class.create();
|
||||||
Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
|
Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
|
||||||
initialize: function(element) {
|
initialize: function(element) {
|
||||||
this.element = $(element);
|
this.element = $(element);
|
||||||
|
if(!this.element) throw(Effect._elementDoesNotExistError);
|
||||||
var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
|
var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
|
||||||
this.start(options);
|
this.start(options);
|
||||||
},
|
},
|
||||||
|
@ -547,8 +570,7 @@ Effect.Fade = function(element) {
|
||||||
to: 0.0,
|
to: 0.0,
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
if(effect.options.to!=0) return;
|
if(effect.options.to!=0) return;
|
||||||
effect.element.hide();
|
effect.element.hide().setStyle({opacity: oldOpacity});
|
||||||
effect.element.setStyle({opacity: oldOpacity});
|
|
||||||
}}, arguments[1] || {});
|
}}, arguments[1] || {});
|
||||||
return new Effect.Opacity(element,options);
|
return new Effect.Opacity(element,options);
|
||||||
}
|
}
|
||||||
|
@ -563,25 +585,31 @@ Effect.Appear = function(element) {
|
||||||
effect.element.forceRerendering();
|
effect.element.forceRerendering();
|
||||||
},
|
},
|
||||||
beforeSetup: function(effect) {
|
beforeSetup: function(effect) {
|
||||||
effect.element.setOpacity(effect.options.from);
|
effect.element.setOpacity(effect.options.from).show();
|
||||||
effect.element.show();
|
|
||||||
}}, arguments[1] || {});
|
}}, arguments[1] || {});
|
||||||
return new Effect.Opacity(element,options);
|
return new Effect.Opacity(element,options);
|
||||||
}
|
}
|
||||||
|
|
||||||
Effect.Puff = function(element) {
|
Effect.Puff = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
var oldStyle = { opacity: element.getInlineOpacity(), position: element.getStyle('position') };
|
var oldStyle = {
|
||||||
|
opacity: element.getInlineOpacity(),
|
||||||
|
position: element.getStyle('position'),
|
||||||
|
top: element.style.top,
|
||||||
|
left: element.style.left,
|
||||||
|
width: element.style.width,
|
||||||
|
height: element.style.height
|
||||||
|
};
|
||||||
return new Effect.Parallel(
|
return new Effect.Parallel(
|
||||||
[ new Effect.Scale(element, 200,
|
[ new Effect.Scale(element, 200,
|
||||||
{ sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
|
{ sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
|
||||||
new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
|
new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
|
||||||
Object.extend({ duration: 1.0,
|
Object.extend({ duration: 1.0,
|
||||||
beforeSetupInternal: function(effect) {
|
beforeSetupInternal: function(effect) {
|
||||||
effect.effects[0].element.setStyle({position: 'absolute'}); },
|
Position.absolutize(effect.effects[0].element)
|
||||||
|
},
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
effect.effects[0].element.hide();
|
effect.effects[0].element.hide().setStyle(oldStyle); }
|
||||||
effect.effects[0].element.setStyle(oldStyle); }
|
|
||||||
}, arguments[1] || {})
|
}, arguments[1] || {})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -589,13 +617,12 @@ Effect.Puff = function(element) {
|
||||||
Effect.BlindUp = function(element) {
|
Effect.BlindUp = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
element.makeClipping();
|
element.makeClipping();
|
||||||
return new Effect.Scale(element, 0,
|
return new Effect.Scale(element, 0,
|
||||||
Object.extend({ scaleContent: false,
|
Object.extend({ scaleContent: false,
|
||||||
scaleX: false,
|
scaleX: false,
|
||||||
restoreAfterFinish: true,
|
restoreAfterFinish: true,
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
effect.element.hide();
|
effect.element.hide().undoClipping();
|
||||||
effect.element.undoClipping();
|
|
||||||
}
|
}
|
||||||
}, arguments[1] || {})
|
}, arguments[1] || {})
|
||||||
);
|
);
|
||||||
|
@ -604,28 +631,25 @@ Effect.BlindUp = function(element) {
|
||||||
Effect.BlindDown = function(element) {
|
Effect.BlindDown = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
var elementDimensions = element.getDimensions();
|
var elementDimensions = element.getDimensions();
|
||||||
return new Effect.Scale(element, 100,
|
return new Effect.Scale(element, 100, Object.extend({
|
||||||
Object.extend({ scaleContent: false,
|
scaleContent: false,
|
||||||
scaleX: false,
|
scaleX: false,
|
||||||
scaleFrom: 0,
|
scaleFrom: 0,
|
||||||
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
|
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
|
||||||
restoreAfterFinish: true,
|
restoreAfterFinish: true,
|
||||||
afterSetup: function(effect) {
|
afterSetup: function(effect) {
|
||||||
effect.element.makeClipping();
|
effect.element.makeClipping().setStyle({height: '0px'}).show();
|
||||||
effect.element.setStyle({height: '0px'});
|
},
|
||||||
effect.element.show();
|
afterFinishInternal: function(effect) {
|
||||||
},
|
effect.element.undoClipping();
|
||||||
afterFinishInternal: function(effect) {
|
}
|
||||||
effect.element.undoClipping();
|
}, arguments[1] || {}));
|
||||||
}
|
|
||||||
}, arguments[1] || {})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Effect.SwitchOff = function(element) {
|
Effect.SwitchOff = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
var oldOpacity = element.getInlineOpacity();
|
var oldOpacity = element.getInlineOpacity();
|
||||||
return new Effect.Appear(element, {
|
return new Effect.Appear(element, Object.extend({
|
||||||
duration: 0.4,
|
duration: 0.4,
|
||||||
from: 0,
|
from: 0,
|
||||||
transition: Effect.Transitions.flicker,
|
transition: Effect.Transitions.flicker,
|
||||||
|
@ -634,18 +658,14 @@ Effect.SwitchOff = function(element) {
|
||||||
duration: 0.3, scaleFromCenter: true,
|
duration: 0.3, scaleFromCenter: true,
|
||||||
scaleX: false, scaleContent: false, restoreAfterFinish: true,
|
scaleX: false, scaleContent: false, restoreAfterFinish: true,
|
||||||
beforeSetup: function(effect) {
|
beforeSetup: function(effect) {
|
||||||
effect.element.makePositioned();
|
effect.element.makePositioned().makeClipping();
|
||||||
effect.element.makeClipping();
|
|
||||||
},
|
},
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
effect.element.hide();
|
effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity});
|
||||||
effect.element.undoClipping();
|
|
||||||
effect.element.undoPositioned();
|
|
||||||
effect.element.setStyle({opacity: oldOpacity});
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
}, arguments[1] || {}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Effect.DropOut = function(element) {
|
Effect.DropOut = function(element) {
|
||||||
|
@ -663,9 +683,7 @@ Effect.DropOut = function(element) {
|
||||||
effect.effects[0].element.makePositioned();
|
effect.effects[0].element.makePositioned();
|
||||||
},
|
},
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
effect.effects[0].element.hide();
|
effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
|
||||||
effect.effects[0].element.undoPositioned();
|
|
||||||
effect.effects[0].element.setStyle(oldStyle);
|
|
||||||
}
|
}
|
||||||
}, arguments[1] || {}));
|
}, arguments[1] || {}));
|
||||||
}
|
}
|
||||||
|
@ -687,54 +705,42 @@ Effect.Shake = function(element) {
|
||||||
{ x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
|
{ x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
|
||||||
new Effect.Move(effect.element,
|
new Effect.Move(effect.element,
|
||||||
{ x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
|
{ x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
|
||||||
effect.element.undoPositioned();
|
effect.element.undoPositioned().setStyle(oldStyle);
|
||||||
effect.element.setStyle(oldStyle);
|
|
||||||
}}) }}) }}) }}) }}) }});
|
}}) }}) }}) }}) }}) }});
|
||||||
}
|
}
|
||||||
|
|
||||||
Effect.SlideDown = function(element) {
|
Effect.SlideDown = function(element) {
|
||||||
element = $(element);
|
element = $(element).cleanWhitespace();
|
||||||
element.cleanWhitespace();
|
|
||||||
// SlideDown need to have the content of the element wrapped in a container element with fixed height!
|
// SlideDown need to have the content of the element wrapped in a container element with fixed height!
|
||||||
var oldInnerBottom = $(element.firstChild).getStyle('bottom');
|
var oldInnerBottom = element.down().getStyle('bottom');
|
||||||
var elementDimensions = element.getDimensions();
|
var elementDimensions = element.getDimensions();
|
||||||
return new Effect.Scale(element, 100, Object.extend({
|
return new Effect.Scale(element, 100, Object.extend({
|
||||||
scaleContent: false,
|
scaleContent: false,
|
||||||
scaleX: false,
|
scaleX: false,
|
||||||
scaleFrom: 0,
|
scaleFrom: window.opera ? 0 : 1,
|
||||||
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
|
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
|
||||||
restoreAfterFinish: true,
|
restoreAfterFinish: true,
|
||||||
afterSetup: function(effect) {
|
afterSetup: function(effect) {
|
||||||
effect.element.makePositioned();
|
effect.element.makePositioned();
|
||||||
effect.element.firstChild.makePositioned();
|
effect.element.down().makePositioned();
|
||||||
if(window.opera) effect.element.setStyle({top: ''});
|
if(window.opera) effect.element.setStyle({top: ''});
|
||||||
effect.element.makeClipping();
|
effect.element.makeClipping().setStyle({height: '0px'}).show();
|
||||||
effect.element.setStyle({height: '0px'});
|
},
|
||||||
effect.element.show(); },
|
|
||||||
afterUpdateInternal: function(effect) {
|
afterUpdateInternal: function(effect) {
|
||||||
effect.element.firstChild.setStyle({bottom:
|
effect.element.down().setStyle({bottom:
|
||||||
(effect.dims[0] - effect.element.clientHeight) + 'px' });
|
(effect.dims[0] - effect.element.clientHeight) + 'px' });
|
||||||
},
|
},
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
effect.element.undoClipping();
|
effect.element.undoClipping().undoPositioned();
|
||||||
// IE will crash if child is undoPositioned first
|
effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
|
||||||
if(/MSIE/.test(navigator.userAgent)){
|
|
||||||
effect.element.undoPositioned();
|
|
||||||
effect.element.firstChild.undoPositioned();
|
|
||||||
}else{
|
|
||||||
effect.element.firstChild.undoPositioned();
|
|
||||||
effect.element.undoPositioned();
|
|
||||||
}
|
|
||||||
effect.element.firstChild.setStyle({bottom: oldInnerBottom}); }
|
|
||||||
}, arguments[1] || {})
|
}, arguments[1] || {})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Effect.SlideUp = function(element) {
|
Effect.SlideUp = function(element) {
|
||||||
element = $(element);
|
element = $(element).cleanWhitespace();
|
||||||
element.cleanWhitespace();
|
var oldInnerBottom = element.down().getStyle('bottom');
|
||||||
var oldInnerBottom = $(element.firstChild).getStyle('bottom');
|
return new Effect.Scale(element, window.opera ? 0 : 1,
|
||||||
return new Effect.Scale(element, 0,
|
|
||||||
Object.extend({ scaleContent: false,
|
Object.extend({ scaleContent: false,
|
||||||
scaleX: false,
|
scaleX: false,
|
||||||
scaleMode: 'box',
|
scaleMode: 'box',
|
||||||
|
@ -742,32 +748,32 @@ Effect.SlideUp = function(element) {
|
||||||
restoreAfterFinish: true,
|
restoreAfterFinish: true,
|
||||||
beforeStartInternal: function(effect) {
|
beforeStartInternal: function(effect) {
|
||||||
effect.element.makePositioned();
|
effect.element.makePositioned();
|
||||||
effect.element.firstChild.makePositioned();
|
effect.element.down().makePositioned();
|
||||||
if(window.opera) effect.element.setStyle({top: ''});
|
if(window.opera) effect.element.setStyle({top: ''});
|
||||||
effect.element.makeClipping();
|
effect.element.makeClipping().show();
|
||||||
effect.element.show(); },
|
},
|
||||||
afterUpdateInternal: function(effect) {
|
afterUpdateInternal: function(effect) {
|
||||||
effect.element.firstChild.setStyle({bottom:
|
effect.element.down().setStyle({bottom:
|
||||||
(effect.dims[0] - effect.element.clientHeight) + 'px' }); },
|
(effect.dims[0] - effect.element.clientHeight) + 'px' });
|
||||||
|
},
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
effect.element.hide();
|
effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom});
|
||||||
effect.element.undoClipping();
|
effect.element.down().undoPositioned();
|
||||||
effect.element.firstChild.undoPositioned();
|
}
|
||||||
effect.element.undoPositioned();
|
|
||||||
effect.element.setStyle({bottom: oldInnerBottom}); }
|
|
||||||
}, arguments[1] || {})
|
}, arguments[1] || {})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bug in opera makes the TD containing this element expand for a instance after finish
|
// Bug in opera makes the TD containing this element expand for a instance after finish
|
||||||
Effect.Squish = function(element) {
|
Effect.Squish = function(element) {
|
||||||
return new Effect.Scale(element, window.opera ? 1 : 0,
|
return new Effect.Scale(element, window.opera ? 1 : 0, {
|
||||||
{ restoreAfterFinish: true,
|
restoreAfterFinish: true,
|
||||||
beforeSetup: function(effect) {
|
beforeSetup: function(effect) {
|
||||||
effect.element.makeClipping(effect.element); },
|
effect.element.makeClipping();
|
||||||
afterFinishInternal: function(effect) {
|
},
|
||||||
effect.element.hide(effect.element);
|
afterFinishInternal: function(effect) {
|
||||||
effect.element.undoClipping(effect.element); }
|
effect.element.hide().undoClipping();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,9 +829,7 @@ Effect.Grow = function(element) {
|
||||||
y: initialMoveY,
|
y: initialMoveY,
|
||||||
duration: 0.01,
|
duration: 0.01,
|
||||||
beforeSetup: function(effect) {
|
beforeSetup: function(effect) {
|
||||||
effect.element.hide();
|
effect.element.hide().makeClipping().makePositioned();
|
||||||
effect.element.makeClipping();
|
|
||||||
effect.element.makePositioned();
|
|
||||||
},
|
},
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
new Effect.Parallel(
|
new Effect.Parallel(
|
||||||
|
@ -836,13 +840,10 @@ Effect.Grow = function(element) {
|
||||||
sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
|
sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
|
||||||
], Object.extend({
|
], Object.extend({
|
||||||
beforeSetup: function(effect) {
|
beforeSetup: function(effect) {
|
||||||
effect.effects[0].element.setStyle({height: '0px'});
|
effect.effects[0].element.setStyle({height: '0px'}).show();
|
||||||
effect.effects[0].element.show();
|
|
||||||
},
|
},
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
effect.effects[0].element.undoClipping();
|
effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);
|
||||||
effect.effects[0].element.undoPositioned();
|
|
||||||
effect.effects[0].element.setStyle(oldStyle);
|
|
||||||
}
|
}
|
||||||
}, options)
|
}, options)
|
||||||
)
|
)
|
||||||
|
@ -896,13 +897,10 @@ Effect.Shrink = function(element) {
|
||||||
new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
|
new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
|
||||||
], Object.extend({
|
], Object.extend({
|
||||||
beforeStartInternal: function(effect) {
|
beforeStartInternal: function(effect) {
|
||||||
effect.effects[0].element.makePositioned();
|
effect.effects[0].element.makePositioned().makeClipping();
|
||||||
effect.effects[0].element.makeClipping(); },
|
},
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
effect.effects[0].element.hide();
|
effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
|
||||||
effect.effects[0].element.undoClipping();
|
|
||||||
effect.effects[0].element.undoPositioned();
|
|
||||||
effect.effects[0].element.setStyle(oldStyle); }
|
|
||||||
}, options)
|
}, options)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -912,10 +910,10 @@ Effect.Pulsate = function(element) {
|
||||||
var options = arguments[1] || {};
|
var options = arguments[1] || {};
|
||||||
var oldOpacity = element.getInlineOpacity();
|
var oldOpacity = element.getInlineOpacity();
|
||||||
var transition = options.transition || Effect.Transitions.sinoidal;
|
var transition = options.transition || Effect.Transitions.sinoidal;
|
||||||
var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
|
var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) };
|
||||||
reverser.bind(transition);
|
reverser.bind(transition);
|
||||||
return new Effect.Opacity(element,
|
return new Effect.Opacity(element,
|
||||||
Object.extend(Object.extend({ duration: 3.0, from: 0,
|
Object.extend(Object.extend({ duration: 2.0, from: 0,
|
||||||
afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
|
afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
|
||||||
}, options), {transition: reverser}));
|
}, options), {transition: reverser}));
|
||||||
}
|
}
|
||||||
|
@ -927,7 +925,7 @@ Effect.Fold = function(element) {
|
||||||
left: element.style.left,
|
left: element.style.left,
|
||||||
width: element.style.width,
|
width: element.style.width,
|
||||||
height: element.style.height };
|
height: element.style.height };
|
||||||
Element.makeClipping(element);
|
element.makeClipping();
|
||||||
return new Effect.Scale(element, 5, Object.extend({
|
return new Effect.Scale(element, 5, Object.extend({
|
||||||
scaleContent: false,
|
scaleContent: false,
|
||||||
scaleX: false,
|
scaleX: false,
|
||||||
|
@ -936,15 +934,147 @@ Effect.Fold = function(element) {
|
||||||
scaleContent: false,
|
scaleContent: false,
|
||||||
scaleY: false,
|
scaleY: false,
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
effect.element.hide();
|
effect.element.hide().undoClipping().setStyle(oldStyle);
|
||||||
effect.element.undoClipping();
|
|
||||||
effect.element.setStyle(oldStyle);
|
|
||||||
} });
|
} });
|
||||||
}}, arguments[1] || {}));
|
}}, arguments[1] || {}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Effect.Morph = Class.create();
|
||||||
|
Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
|
||||||
|
initialize: function(element) {
|
||||||
|
this.element = $(element);
|
||||||
|
if(!this.element) throw(Effect._elementDoesNotExistError);
|
||||||
|
var options = Object.extend({
|
||||||
|
style: ''
|
||||||
|
}, arguments[1] || {});
|
||||||
|
this.start(options);
|
||||||
|
},
|
||||||
|
setup: function(){
|
||||||
|
function parseColor(color){
|
||||||
|
if(!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
|
||||||
|
color = color.parseColor();
|
||||||
|
return $R(0,2).map(function(i){
|
||||||
|
return parseInt( color.slice(i*2+1,i*2+3), 16 )
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.transforms = this.options.style.parseStyle().map(function(property){
|
||||||
|
var originalValue = this.element.getStyle(property[0]);
|
||||||
|
return $H({
|
||||||
|
style: property[0],
|
||||||
|
originalValue: property[1].unit=='color' ?
|
||||||
|
parseColor(originalValue) : parseFloat(originalValue || 0),
|
||||||
|
targetValue: property[1].unit=='color' ?
|
||||||
|
parseColor(property[1].value) : property[1].value,
|
||||||
|
unit: property[1].unit
|
||||||
|
});
|
||||||
|
}.bind(this)).reject(function(transform){
|
||||||
|
return (
|
||||||
|
(transform.originalValue == transform.targetValue) ||
|
||||||
|
(
|
||||||
|
transform.unit != 'color' &&
|
||||||
|
(isNaN(transform.originalValue) || isNaN(transform.targetValue))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
update: function(position) {
|
||||||
|
var style = $H(), value = null;
|
||||||
|
this.transforms.each(function(transform){
|
||||||
|
value = transform.unit=='color' ?
|
||||||
|
$R(0,2).inject('#',function(m,v,i){
|
||||||
|
return m+(Math.round(transform.originalValue[i]+
|
||||||
|
(transform.targetValue[i] - transform.originalValue[i])*position)).toColorPart() }) :
|
||||||
|
transform.originalValue + Math.round(
|
||||||
|
((transform.targetValue - transform.originalValue) * position) * 1000)/1000 + transform.unit;
|
||||||
|
style[transform.style] = value;
|
||||||
|
});
|
||||||
|
this.element.setStyle(style);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.Transform = Class.create();
|
||||||
|
Object.extend(Effect.Transform.prototype, {
|
||||||
|
initialize: function(tracks){
|
||||||
|
this.tracks = [];
|
||||||
|
this.options = arguments[1] || {};
|
||||||
|
this.addTracks(tracks);
|
||||||
|
},
|
||||||
|
addTracks: function(tracks){
|
||||||
|
tracks.each(function(track){
|
||||||
|
var data = $H(track).values().first();
|
||||||
|
this.tracks.push($H({
|
||||||
|
ids: $H(track).keys().first(),
|
||||||
|
effect: Effect.Morph,
|
||||||
|
options: { style: data }
|
||||||
|
}));
|
||||||
|
}.bind(this));
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
play: function(){
|
||||||
|
return new Effect.Parallel(
|
||||||
|
this.tracks.map(function(track){
|
||||||
|
var elements = [$(track.ids) || $$(track.ids)].flatten();
|
||||||
|
return elements.map(function(e){ return new track.effect(e, Object.extend({ sync:true }, track.options)) });
|
||||||
|
}).flatten(),
|
||||||
|
this.options
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Element.CSS_PROPERTIES = ['azimuth', 'backgroundAttachment', 'backgroundColor', 'backgroundImage',
|
||||||
|
'backgroundPosition', 'backgroundRepeat', 'borderBottomColor', 'borderBottomStyle',
|
||||||
|
'borderBottomWidth', 'borderCollapse', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth',
|
||||||
|
'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderSpacing', 'borderTopColor',
|
||||||
|
'borderTopStyle', 'borderTopWidth', 'bottom', 'captionSide', 'clear', 'clip', 'color', 'content',
|
||||||
|
'counterIncrement', 'counterReset', 'cssFloat', 'cueAfter', 'cueBefore', 'cursor', 'direction',
|
||||||
|
'display', 'elevation', 'emptyCells', 'fontFamily', 'fontSize', 'fontSizeAdjust', 'fontStretch',
|
||||||
|
'fontStyle', 'fontVariant', 'fontWeight', 'height', 'left', 'letterSpacing', 'lineHeight',
|
||||||
|
'listStyleImage', 'listStylePosition', 'listStyleType', 'marginBottom', 'marginLeft', 'marginRight',
|
||||||
|
'marginTop', 'markerOffset', 'marks', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'opacity',
|
||||||
|
'orphans', 'outlineColor', 'outlineOffset', 'outlineStyle', 'outlineWidth', 'overflowX', 'overflowY',
|
||||||
|
'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', 'page', 'pageBreakAfter', 'pageBreakBefore',
|
||||||
|
'pageBreakInside', 'pauseAfter', 'pauseBefore', 'pitch', 'pitchRange', 'position', 'quotes',
|
||||||
|
'richness', 'right', 'size', 'speakHeader', 'speakNumeral', 'speakPunctuation', 'speechRate', 'stress',
|
||||||
|
'tableLayout', 'textAlign', 'textDecoration', 'textIndent', 'textShadow', 'textTransform', 'top',
|
||||||
|
'unicodeBidi', 'verticalAlign', 'visibility', 'voiceFamily', 'volume', 'whiteSpace', 'widows',
|
||||||
|
'width', 'wordSpacing', 'zIndex'];
|
||||||
|
|
||||||
|
Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
|
||||||
|
|
||||||
|
String.prototype.parseStyle = function(){
|
||||||
|
var element = Element.extend(document.createElement('div'));
|
||||||
|
element.innerHTML = '<div style="' + this + '"></div>';
|
||||||
|
var style = element.down().style, styleRules = $H();
|
||||||
|
|
||||||
|
Element.CSS_PROPERTIES.each(function(property){
|
||||||
|
if(style[property]) styleRules[property] = style[property];
|
||||||
|
});
|
||||||
|
|
||||||
|
var result = $H();
|
||||||
|
|
||||||
|
styleRules.each(function(pair){
|
||||||
|
var property = pair[0], value = pair[1], unit = null;
|
||||||
|
|
||||||
|
if(value.parseColor('#zzzzzz') != '#zzzzzz') {
|
||||||
|
value = value.parseColor();
|
||||||
|
unit = 'color';
|
||||||
|
} else if(Element.CSS_LENGTH.test(value))
|
||||||
|
var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/),
|
||||||
|
value = parseFloat(components[1]), unit = (components.length == 3) ? components[2] : null;
|
||||||
|
|
||||||
|
result[property.underscore().dasherize()] = $H({ value:value, unit:unit });
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
Element.morph = function(element, style) {
|
||||||
|
new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || {}));
|
||||||
|
return element;
|
||||||
|
};
|
||||||
|
|
||||||
['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
|
['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
|
||||||
'collectTextNodes','collectTextNodesIgnoreClass','childrenWithClassName'].each(
|
'collectTextNodes','collectTextNodesIgnoreClass','morph'].each(
|
||||||
function(f) { Element.Methods[f] = Element[f]; }
|
function(f) { Element.Methods[f] = Element[f]; }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
1321
public/javascripts/prototype.js
vendored
1321
public/javascripts/prototype.js
vendored
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue