Finish Rails-ifying the tree. Adds missing files and directories and
brings a few miscellaneous files up to date.
This commit is contained in:
parent
503aa99c63
commit
50343b79e8
|
@ -3,6 +3,13 @@ AddHandler fastcgi-script .fcgi
|
||||||
AddHandler cgi-script .cgi
|
AddHandler cgi-script .cgi
|
||||||
Options +FollowSymLinks +ExecCGI
|
Options +FollowSymLinks +ExecCGI
|
||||||
|
|
||||||
|
# If you don't want Rails to look in certain directories,
|
||||||
|
# use the following rewrite rules so that Apache won't rewrite certain requests
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# RewriteCond %{REQUEST_URI} ^/notrails.*
|
||||||
|
# RewriteRule .* - [L]
|
||||||
|
|
||||||
# Redirect all requests not available on the filesystem to Rails
|
# Redirect all requests not available on the filesystem to Rails
|
||||||
# By default the cgi dispatcher is used which is very slow
|
# By default the cgi dispatcher is used which is very slow
|
||||||
#
|
#
|
||||||
|
@ -14,7 +21,7 @@ RewriteEngine On
|
||||||
RewriteRule ^$ index.html [QSA]
|
RewriteRule ^$ index.html [QSA]
|
||||||
RewriteRule ^([^.]+)$ $1.html [QSA]
|
RewriteRule ^([^.]+)$ $1.html [QSA]
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
|
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
|
||||||
|
|
||||||
# In case Rails experiences terminal errors
|
# In case Rails experiences terminal errors
|
||||||
# Instead of displaying this message you can supply a file here which will be rendered instead
|
# Instead of displaying this message you can supply a file here which will be rendered instead
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<h1>File not found</h1>
|
<h1>File not found</h1>
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<h1>Application error (Apache)</h1>
|
<h1>Application error (Apache)</h1>
|
||||||
|
|
10
public/dispatch.cgi
Executable file
10
public/dispatch.cgi
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/ruby1.8
|
||||||
|
|
||||||
|
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
|
||||||
|
|
||||||
|
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
|
||||||
|
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
|
||||||
|
require "dispatcher"
|
||||||
|
|
||||||
|
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
|
||||||
|
Dispatcher.dispatch
|
24
public/dispatch.fcgi
Executable file
24
public/dispatch.fcgi
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/ruby1.8
|
||||||
|
#
|
||||||
|
# You may specify the path to the FastCGI crash log (a log of unhandled
|
||||||
|
# exceptions which forced the FastCGI instance to exit, great for debugging)
|
||||||
|
# and the number of requests to process before running garbage collection.
|
||||||
|
#
|
||||||
|
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
|
||||||
|
# and the GC period is nil (turned off). A reasonable number of requests
|
||||||
|
# could range from 10-100 depending on the memory footprint of your app.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# # Default log path, normal GC behavior.
|
||||||
|
# RailsFCGIHandler.process!
|
||||||
|
#
|
||||||
|
# # Default log path, 50 requests between GC.
|
||||||
|
# RailsFCGIHandler.process! nil, 50
|
||||||
|
#
|
||||||
|
# # Custom log path, normal GC behavior.
|
||||||
|
# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
|
||||||
|
#
|
||||||
|
require File.dirname(__FILE__) + "/../config/environment"
|
||||||
|
require 'fcgi_handler'
|
||||||
|
|
||||||
|
RailsFCGIHandler.process!
|
Binary file not shown.
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 0 B |
446
public/javascripts/controls.js
vendored
Normal file
446
public/javascripts/controls.js
vendored
Normal file
|
@ -0,0 +1,446 @@
|
||||||
|
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
|
// (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
// a copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Element.collectTextNodesIgnoreClass = function(element, ignoreclass) {
|
||||||
|
var children = $(element).childNodes;
|
||||||
|
var text = "";
|
||||||
|
var classtest = new RegExp("^([^ ]+ )*" + ignoreclass+ "( [^ ]+)*$","i");
|
||||||
|
|
||||||
|
for (var i = 0; i < children.length; i++) {
|
||||||
|
if(children[i].nodeType==3) {
|
||||||
|
text+=children[i].nodeValue;
|
||||||
|
} else {
|
||||||
|
if((!children[i].className.match(classtest)) && children[i].hasChildNodes())
|
||||||
|
text += Element.collectTextNodesIgnoreClass(children[i], ignoreclass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Autocompleter.Base handles all the autocompletion functionality
|
||||||
|
// that's independent of the data source for autocompletion. This
|
||||||
|
// includes drawing the autocompletion menu, observing keyboard
|
||||||
|
// and mouse events, and similar.
|
||||||
|
//
|
||||||
|
// Specific autocompleters need to provide, at the very least,
|
||||||
|
// a getUpdatedChoices function that will be invoked every time
|
||||||
|
// the text inside the monitored textbox changes. This method
|
||||||
|
// should get the text for which to provide autocompletion by
|
||||||
|
// invoking this.getEntry(), NOT by directly accessing
|
||||||
|
// this.element.value. This is to allow incremental tokenized
|
||||||
|
// autocompletion. Specific auto-completion logic (AJAX, etc)
|
||||||
|
// belongs in getUpdatedChoices.
|
||||||
|
//
|
||||||
|
// Tokenized incremental autocompletion is enabled automatically
|
||||||
|
// when an autocompleter is instantiated with the 'tokens' option
|
||||||
|
// in the options parameter, e.g.:
|
||||||
|
// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
|
||||||
|
// will incrementally autocomplete with a comma as the token.
|
||||||
|
// Additionally, ',' in the above example can be replaced with
|
||||||
|
// a token array, e.g. { tokens: new Array (',', '\n') } which
|
||||||
|
// enables autocompletion on multiple tokens. This is most
|
||||||
|
// useful when one of the tokens is \n (a newline), as it
|
||||||
|
// allows smart autocompletion after linebreaks.
|
||||||
|
|
||||||
|
var Autocompleter = {}
|
||||||
|
Autocompleter.Base = function() {};
|
||||||
|
Autocompleter.Base.prototype = {
|
||||||
|
base_initialize: function(element, update, options) {
|
||||||
|
this.element = $(element);
|
||||||
|
this.update = $(update);
|
||||||
|
this.has_focus = false;
|
||||||
|
this.changed = false;
|
||||||
|
this.active = false;
|
||||||
|
this.index = 0;
|
||||||
|
this.entry_count = 0;
|
||||||
|
|
||||||
|
if (this.setOptions)
|
||||||
|
this.setOptions(options);
|
||||||
|
else
|
||||||
|
this.options = {}
|
||||||
|
|
||||||
|
this.options.tokens = this.options.tokens || new Array();
|
||||||
|
this.options.frequency = this.options.frequency || 0.4;
|
||||||
|
this.options.min_chars = this.options.min_chars || 1;
|
||||||
|
this.options.onShow = this.options.onShow ||
|
||||||
|
function(element, update){
|
||||||
|
if(!update.style.position || update.style.position=='absolute') {
|
||||||
|
update.style.position = 'absolute';
|
||||||
|
var offsets = Position.cumulativeOffset(element);
|
||||||
|
update.style.left = offsets[0] + 'px';
|
||||||
|
update.style.top = (offsets[1] + element.offsetHeight) + 'px';
|
||||||
|
update.style.width = element.offsetWidth + 'px';
|
||||||
|
}
|
||||||
|
new Effect.Appear(update,{duration:0.15});
|
||||||
|
};
|
||||||
|
this.options.onHide = this.options.onHide ||
|
||||||
|
function(element, update){ new Effect.Fade(update,{duration:0.15}) };
|
||||||
|
|
||||||
|
if(this.options.indicator)
|
||||||
|
this.indicator = $(this.options.indicator);
|
||||||
|
|
||||||
|
if (typeof(this.options.tokens) == 'string')
|
||||||
|
this.options.tokens = new Array(this.options.tokens);
|
||||||
|
|
||||||
|
this.observer = null;
|
||||||
|
|
||||||
|
Element.hide(this.update);
|
||||||
|
|
||||||
|
Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));
|
||||||
|
Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
show: function() {
|
||||||
|
if(this.update.style.display=='none') this.options.onShow(this.element, this.update);
|
||||||
|
if(!this.iefix && (navigator.appVersion.indexOf('MSIE')>0) && this.update.style.position=='absolute') {
|
||||||
|
new Insertion.After(this.update,
|
||||||
|
'<iframe id="' + this.update.id + '_iefix" '+
|
||||||
|
'style="display:none;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
|
||||||
|
'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
|
||||||
|
this.iefix = $(this.update.id+'_iefix');
|
||||||
|
}
|
||||||
|
if(this.iefix) {
|
||||||
|
Position.clone(this.update, this.iefix);
|
||||||
|
this.iefix.style.zIndex = 1;
|
||||||
|
this.update.style.zIndex = 2;
|
||||||
|
Element.show(this.iefix);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
hide: function() {
|
||||||
|
if(this.update.style.display=='') this.options.onHide(this.element, this.update);
|
||||||
|
if(this.iefix) Element.hide(this.iefix);
|
||||||
|
},
|
||||||
|
|
||||||
|
startIndicator: function() {
|
||||||
|
if(this.indicator) Element.show(this.indicator);
|
||||||
|
},
|
||||||
|
|
||||||
|
stopIndicator: function() {
|
||||||
|
if(this.indicator) Element.hide(this.indicator);
|
||||||
|
},
|
||||||
|
|
||||||
|
onKeyPress: function(event) {
|
||||||
|
if(this.active)
|
||||||
|
switch(event.keyCode) {
|
||||||
|
case Event.KEY_TAB:
|
||||||
|
case Event.KEY_RETURN:
|
||||||
|
this.select_entry();
|
||||||
|
Event.stop(event);
|
||||||
|
case Event.KEY_ESC:
|
||||||
|
this.hide();
|
||||||
|
this.active = false;
|
||||||
|
return;
|
||||||
|
case Event.KEY_LEFT:
|
||||||
|
case Event.KEY_RIGHT:
|
||||||
|
return;
|
||||||
|
case Event.KEY_UP:
|
||||||
|
this.mark_previous();
|
||||||
|
this.render();
|
||||||
|
if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
|
||||||
|
return;
|
||||||
|
case Event.KEY_DOWN:
|
||||||
|
this.mark_next();
|
||||||
|
this.render();
|
||||||
|
if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.changed = true;
|
||||||
|
this.has_focus = true;
|
||||||
|
|
||||||
|
if(this.observer) clearTimeout(this.observer);
|
||||||
|
this.observer =
|
||||||
|
setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
|
||||||
|
},
|
||||||
|
|
||||||
|
onHover: function(event) {
|
||||||
|
var element = Event.findElement(event, 'LI');
|
||||||
|
if(this.index != element.autocompleteIndex)
|
||||||
|
{
|
||||||
|
this.index = element.autocompleteIndex;
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
Event.stop(event);
|
||||||
|
},
|
||||||
|
|
||||||
|
onClick: function(event) {
|
||||||
|
var element = Event.findElement(event, 'LI');
|
||||||
|
this.index = element.autocompleteIndex;
|
||||||
|
this.select_entry();
|
||||||
|
Event.stop(event);
|
||||||
|
},
|
||||||
|
|
||||||
|
onBlur: function(event) {
|
||||||
|
// needed to make click events working
|
||||||
|
setTimeout(this.hide.bind(this), 250);
|
||||||
|
this.has_focus = false;
|
||||||
|
this.active = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
if(this.entry_count > 0) {
|
||||||
|
for (var i = 0; i < this.entry_count; i++)
|
||||||
|
this.index==i ?
|
||||||
|
Element.addClassName(this.get_entry(i),"selected") :
|
||||||
|
Element.removeClassName(this.get_entry(i),"selected");
|
||||||
|
|
||||||
|
if(this.has_focus) {
|
||||||
|
if(this.get_current_entry().scrollIntoView)
|
||||||
|
this.get_current_entry().scrollIntoView(false);
|
||||||
|
|
||||||
|
this.show();
|
||||||
|
this.active = true;
|
||||||
|
}
|
||||||
|
} else this.hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
mark_previous: function() {
|
||||||
|
if(this.index > 0) this.index--
|
||||||
|
else this.index = this.entry_count-1;
|
||||||
|
},
|
||||||
|
|
||||||
|
mark_next: function() {
|
||||||
|
if(this.index < this.entry_count-1) this.index++
|
||||||
|
else this.index = 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
get_entry: function(index) {
|
||||||
|
return this.update.firstChild.childNodes[index];
|
||||||
|
},
|
||||||
|
|
||||||
|
get_current_entry: function() {
|
||||||
|
return this.get_entry(this.index);
|
||||||
|
},
|
||||||
|
|
||||||
|
select_entry: function() {
|
||||||
|
this.active = false;
|
||||||
|
value = Element.collectTextNodesIgnoreClass(this.get_current_entry(), 'informal').unescapeHTML();
|
||||||
|
this.updateElement(value);
|
||||||
|
this.element.focus();
|
||||||
|
},
|
||||||
|
|
||||||
|
updateElement: function(value) {
|
||||||
|
var last_token_pos = this.findLastToken();
|
||||||
|
if (last_token_pos != -1) {
|
||||||
|
var new_value = this.element.value.substr(0, last_token_pos + 1);
|
||||||
|
var whitespace = this.element.value.substr(last_token_pos + 1).match(/^\s+/);
|
||||||
|
if (whitespace)
|
||||||
|
new_value += whitespace[0];
|
||||||
|
this.element.value = new_value + value;
|
||||||
|
} else {
|
||||||
|
this.element.value = value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
updateChoices: function(choices) {
|
||||||
|
if(!this.changed && this.has_focus) {
|
||||||
|
this.update.innerHTML = choices;
|
||||||
|
Element.cleanWhitespace(this.update);
|
||||||
|
Element.cleanWhitespace(this.update.firstChild);
|
||||||
|
|
||||||
|
if(this.update.firstChild && this.update.firstChild.childNodes) {
|
||||||
|
this.entry_count =
|
||||||
|
this.update.firstChild.childNodes.length;
|
||||||
|
for (var i = 0; i < this.entry_count; i++) {
|
||||||
|
entry = this.get_entry(i);
|
||||||
|
entry.autocompleteIndex = i;
|
||||||
|
this.addObservers(entry);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.entry_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.stopIndicator();
|
||||||
|
|
||||||
|
this.index = 0;
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
addObservers: function(element) {
|
||||||
|
Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
|
||||||
|
Event.observe(element, "click", this.onClick.bindAsEventListener(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
onObserverEvent: function() {
|
||||||
|
this.changed = false;
|
||||||
|
if(this.getEntry().length>=this.options.min_chars) {
|
||||||
|
this.startIndicator();
|
||||||
|
this.getUpdatedChoices();
|
||||||
|
} else {
|
||||||
|
this.active = false;
|
||||||
|
this.hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getEntry: function() {
|
||||||
|
var token_pos = this.findLastToken();
|
||||||
|
if (token_pos != -1)
|
||||||
|
var ret = this.element.value.substr(token_pos + 1).replace(/^\s+/,'').replace(/\s+$/,'');
|
||||||
|
else
|
||||||
|
var ret = this.element.value;
|
||||||
|
|
||||||
|
return /\n/.test(ret) ? '' : ret;
|
||||||
|
},
|
||||||
|
|
||||||
|
findLastToken: function() {
|
||||||
|
var last_token_pos = -1;
|
||||||
|
|
||||||
|
for (var i=0; i<this.options.tokens.length; i++) {
|
||||||
|
var this_token_pos = this.element.value.lastIndexOf(this.options.tokens[i]);
|
||||||
|
if (this_token_pos > last_token_pos)
|
||||||
|
last_token_pos = this_token_pos;
|
||||||
|
}
|
||||||
|
return last_token_pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ajax.Autocompleter = Class.create();
|
||||||
|
Ajax.Autocompleter.prototype = Object.extend(new Autocompleter.Base(),
|
||||||
|
Object.extend(new Ajax.Base(), {
|
||||||
|
initialize: function(element, update, url, options) {
|
||||||
|
this.base_initialize(element, update, options);
|
||||||
|
this.options.asynchronous = true;
|
||||||
|
this.options.onComplete = this.onComplete.bind(this)
|
||||||
|
this.options.method = 'post';
|
||||||
|
this.options.defaultParams = this.options.parameters || null;
|
||||||
|
this.url = url;
|
||||||
|
},
|
||||||
|
|
||||||
|
getUpdatedChoices: function() {
|
||||||
|
entry = encodeURIComponent(this.element.name) + '=' +
|
||||||
|
encodeURIComponent(this.getEntry());
|
||||||
|
|
||||||
|
this.options.parameters = this.options.callback ?
|
||||||
|
this.options.callback(this.element, entry) : entry;
|
||||||
|
|
||||||
|
if(this.options.defaultParams)
|
||||||
|
this.options.parameters += '&' + this.options.defaultParams;
|
||||||
|
|
||||||
|
new Ajax.Request(this.url, this.options);
|
||||||
|
},
|
||||||
|
|
||||||
|
onComplete: function(request) {
|
||||||
|
this.updateChoices(request.responseText);
|
||||||
|
}
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
// The local array autocompleter. Used when you'd prefer to
|
||||||
|
// inject an array of autocompletion options into the page, rather
|
||||||
|
// than sending out Ajax queries, which can be quite slow sometimes.
|
||||||
|
//
|
||||||
|
// The constructor takes four parameters. The first two are, as usual,
|
||||||
|
// the id of the monitored textbox, and id of the autocompletion menu.
|
||||||
|
// The third is the array you want to autocomplete from, and the fourth
|
||||||
|
// is the options block.
|
||||||
|
//
|
||||||
|
// Extra local autocompletion options:
|
||||||
|
// - choices - How many autocompletion choices to offer
|
||||||
|
//
|
||||||
|
// - partial_search - If false, the autocompleter will match entered
|
||||||
|
// text only at the beginning of strings in the
|
||||||
|
// autocomplete array. Defaults to true, which will
|
||||||
|
// match text at the beginning of any *word* in the
|
||||||
|
// strings in the autocomplete array. If you want to
|
||||||
|
// search anywhere in the string, additionally set
|
||||||
|
// the option full_search to true (default: off).
|
||||||
|
//
|
||||||
|
// - full_search - Search anywhere in autocomplete array strings.
|
||||||
|
//
|
||||||
|
// - partial_chars - How many characters to enter before triggering
|
||||||
|
// a partial match (unlike min_chars, which defines
|
||||||
|
// how many characters are required to do any match
|
||||||
|
// at all). Defaults to 2.
|
||||||
|
//
|
||||||
|
// - ignore_case - Whether to ignore case when autocompleting.
|
||||||
|
// Defaults to true.
|
||||||
|
//
|
||||||
|
// It's possible to pass in a custom function as the 'selector'
|
||||||
|
// option, if you prefer to write your own autocompletion logic.
|
||||||
|
// In that case, the other options above will not apply unless
|
||||||
|
// you support them.
|
||||||
|
|
||||||
|
Autocompleter.Local = Class.create();
|
||||||
|
Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
|
||||||
|
initialize: function(element, update, array, options) {
|
||||||
|
this.base_initialize(element, update, options);
|
||||||
|
this.options.array = array;
|
||||||
|
},
|
||||||
|
|
||||||
|
getUpdatedChoices: function() {
|
||||||
|
this.updateChoices(this.options.selector(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
setOptions: function(options) {
|
||||||
|
this.options = Object.extend({
|
||||||
|
choices: 10,
|
||||||
|
partial_search: true,
|
||||||
|
partial_chars: 2,
|
||||||
|
ignore_case: true,
|
||||||
|
full_search: false,
|
||||||
|
selector: function(instance) {
|
||||||
|
var ret = new Array(); // Beginning matches
|
||||||
|
var partial = new Array(); // Inside matches
|
||||||
|
var entry = instance.getEntry();
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < instance.options.array.length &&
|
||||||
|
ret.length < instance.options.choices ; i++) {
|
||||||
|
var elem = instance.options.array[i];
|
||||||
|
var found_pos = instance.options.ignore_case ?
|
||||||
|
elem.toLowerCase().indexOf(entry.toLowerCase()) :
|
||||||
|
elem.indexOf(entry);
|
||||||
|
|
||||||
|
while (found_pos != -1) {
|
||||||
|
if (found_pos == 0 && elem.length != entry.length) {
|
||||||
|
ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
|
||||||
|
elem.substr(entry.length) + "</li>");
|
||||||
|
break;
|
||||||
|
} else if (entry.length >= instance.options.partial_chars &&
|
||||||
|
instance.options.partial_search && found_pos != -1) {
|
||||||
|
if (instance.options.full_search || /\s/.test(elem.substr(found_pos-1,1))) {
|
||||||
|
partial.push("<li>" + elem.substr(0, found_pos) + "<strong>" +
|
||||||
|
elem.substr(found_pos, entry.length) + "</strong>" + elem.substr(
|
||||||
|
found_pos + entry.length) + "</li>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
found_pos = instance.options.ignore_case ?
|
||||||
|
elem.toLowerCase().indexOf(entry.toLowerCase(), found_pos + 1) :
|
||||||
|
elem.indexOf(entry, found_pos + 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (partial.length)
|
||||||
|
ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
|
||||||
|
return "<ul>" + ret.join('') + "</ul>";
|
||||||
|
}
|
||||||
|
}, options || {});
|
||||||
|
}
|
||||||
|
});
|
537
public/javascripts/dragdrop.js
vendored
Normal file
537
public/javascripts/dragdrop.js
vendored
Normal file
|
@ -0,0 +1,537 @@
|
||||||
|
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
|
//
|
||||||
|
// Element.Class part Copyright (c) 2005 by Rick Olson
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
// a copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Element.Class = {
|
||||||
|
// Element.toggleClass(element, className) toggles the class being on/off
|
||||||
|
// Element.toggleClass(element, className1, className2) toggles between both classes,
|
||||||
|
// defaulting to className1 if neither exist
|
||||||
|
toggle: function(element, className) {
|
||||||
|
if(Element.Class.has(element, className)) {
|
||||||
|
Element.Class.remove(element, className);
|
||||||
|
if(arguments.length == 3) Element.Class.add(element, arguments[2]);
|
||||||
|
} else {
|
||||||
|
Element.Class.add(element, className);
|
||||||
|
if(arguments.length == 3) Element.Class.remove(element, arguments[2]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// gets space-delimited classnames of an element as an array
|
||||||
|
get: function(element) {
|
||||||
|
element = $(element);
|
||||||
|
return element.className.split(' ');
|
||||||
|
},
|
||||||
|
|
||||||
|
// functions adapted from original functions by Gavin Kistner
|
||||||
|
remove: function(element) {
|
||||||
|
element = $(element);
|
||||||
|
var regEx;
|
||||||
|
for(var i = 1; i < arguments.length; i++) {
|
||||||
|
regEx = new RegExp("^" + arguments[i] + "\\b\\s*|\\s*\\b" + arguments[i] + "\\b", 'g');
|
||||||
|
element.className = element.className.replace(regEx, '')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
add: function(element) {
|
||||||
|
element = $(element);
|
||||||
|
for(var i = 1; i < arguments.length; i++) {
|
||||||
|
Element.Class.remove(element, arguments[i]);
|
||||||
|
element.className += (element.className.length > 0 ? ' ' : '') + arguments[i];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// returns true if all given classes exist in said element
|
||||||
|
has: function(element) {
|
||||||
|
element = $(element);
|
||||||
|
if(!element || !element.className) return false;
|
||||||
|
var regEx;
|
||||||
|
for(var i = 1; i < arguments.length; i++) {
|
||||||
|
regEx = new RegExp("\\b" + arguments[i] + "\\b");
|
||||||
|
if(!regEx.test(element.className)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
// expects arrays of strings and/or strings as optional paramters
|
||||||
|
// Element.Class.has_any(element, ['classA','classB','classC'], 'classD')
|
||||||
|
has_any: function(element) {
|
||||||
|
element = $(element);
|
||||||
|
if(!element || !element.className) return false;
|
||||||
|
var regEx;
|
||||||
|
for(var i = 1; i < arguments.length; i++) {
|
||||||
|
if((typeof arguments[i] == 'object') &&
|
||||||
|
(arguments[i].constructor == Array)) {
|
||||||
|
for(var j = 0; j < arguments[i].length; j++) {
|
||||||
|
regEx = new RegExp("\\b" + arguments[i][j] + "\\b");
|
||||||
|
if(regEx.test(element.className)) return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
regEx = new RegExp("\\b" + arguments[i] + "\\b");
|
||||||
|
if(regEx.test(element.className)) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
childrenWith: function(element, className) {
|
||||||
|
var children = $(element).getElementsByTagName('*');
|
||||||
|
var elements = new Array();
|
||||||
|
|
||||||
|
for (var i = 0; i < children.length; i++) {
|
||||||
|
if (Element.Class.has(children[i], className)) {
|
||||||
|
elements.push(children[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
var Droppables = {
|
||||||
|
drops: false,
|
||||||
|
|
||||||
|
remove: function(element) {
|
||||||
|
for(var i = 0; i < this.drops.length; i++)
|
||||||
|
if(this.drops[i].element == element)
|
||||||
|
this.drops.splice(i,1);
|
||||||
|
},
|
||||||
|
|
||||||
|
add: function(element) {
|
||||||
|
var element = $(element);
|
||||||
|
var options = Object.extend({
|
||||||
|
greedy: true,
|
||||||
|
hoverclass: null
|
||||||
|
}, arguments[1] || {});
|
||||||
|
|
||||||
|
// cache containers
|
||||||
|
if(options.containment) {
|
||||||
|
options._containers = new Array();
|
||||||
|
var containment = options.containment;
|
||||||
|
if((typeof containment == 'object') &&
|
||||||
|
(containment.constructor == Array)) {
|
||||||
|
for(var i=0; i<containment.length; i++)
|
||||||
|
options._containers.push($(containment[i]));
|
||||||
|
} else {
|
||||||
|
options._containers.push($(containment));
|
||||||
|
}
|
||||||
|
options._containers_length =
|
||||||
|
options._containers.length-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Element.makePositioned(element); // fix IE
|
||||||
|
|
||||||
|
options.element = element;
|
||||||
|
|
||||||
|
// activate the droppable
|
||||||
|
if(!this.drops) this.drops = [];
|
||||||
|
this.drops.push(options);
|
||||||
|
},
|
||||||
|
|
||||||
|
is_contained: function(element, drop) {
|
||||||
|
var containers = drop._containers;
|
||||||
|
var parentNode = element.parentNode;
|
||||||
|
var i = drop._containers_length;
|
||||||
|
do { if(parentNode==containers[i]) return true; } while (i--);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
is_affected: function(pX, pY, element, drop) {
|
||||||
|
return (
|
||||||
|
(drop.element!=element) &&
|
||||||
|
((!drop._containers) ||
|
||||||
|
this.is_contained(element, drop)) &&
|
||||||
|
((!drop.accept) ||
|
||||||
|
(Element.Class.has_any(element, drop.accept))) &&
|
||||||
|
Position.within(drop.element, pX, pY) );
|
||||||
|
},
|
||||||
|
|
||||||
|
deactivate: function(drop) {
|
||||||
|
Element.Class.remove(drop.element, drop.hoverclass);
|
||||||
|
this.last_active = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
activate: function(drop) {
|
||||||
|
if(this.last_active) this.deactivate(this.last_active);
|
||||||
|
if(drop.hoverclass) {
|
||||||
|
Element.Class.add(drop.element, drop.hoverclass);
|
||||||
|
this.last_active = drop;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
show: function(event, element) {
|
||||||
|
if(!this.drops) return;
|
||||||
|
var pX = Event.pointerX(event);
|
||||||
|
var pY = Event.pointerY(event);
|
||||||
|
Position.prepare();
|
||||||
|
|
||||||
|
var i = this.drops.length-1; do {
|
||||||
|
var drop = this.drops[i];
|
||||||
|
if(this.is_affected(pX, pY, element, drop)) {
|
||||||
|
if(drop.onHover)
|
||||||
|
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
|
||||||
|
if(drop.greedy) {
|
||||||
|
this.activate(drop);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (i--);
|
||||||
|
},
|
||||||
|
|
||||||
|
fire: function(event, element) {
|
||||||
|
if(!this.last_active) return;
|
||||||
|
Position.prepare();
|
||||||
|
|
||||||
|
if (this.is_affected(Event.pointerX(event), Event.pointerY(event), element, this.last_active))
|
||||||
|
if (this.last_active.onDrop)
|
||||||
|
this.last_active.onDrop(element, this.last_active);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
reset: function() {
|
||||||
|
if(this.last_active)
|
||||||
|
this.deactivate(this.last_active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Draggables = {
|
||||||
|
observers: new Array(),
|
||||||
|
addObserver: function(observer) {
|
||||||
|
this.observers.push(observer);
|
||||||
|
},
|
||||||
|
removeObserver: function(element) { // element instead of obsever fixes mem leaks
|
||||||
|
for(var i = 0; i < this.observers.length; i++)
|
||||||
|
if(this.observers[i].element && (this.observers[i].element == element))
|
||||||
|
this.observers.splice(i,1);
|
||||||
|
},
|
||||||
|
notify: function(eventName, draggable) { // 'onStart', 'onEnd'
|
||||||
|
for(var i = 0; i < this.observers.length; i++)
|
||||||
|
this.observers[i][eventName](draggable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
Draggable = Class.create();
|
||||||
|
Draggable.prototype = {
|
||||||
|
initialize: function(element) {
|
||||||
|
var options = Object.extend({
|
||||||
|
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) {
|
||||||
|
new Effect.MoveBy(element, -top_offset, -left_offset, {duration:0.4});
|
||||||
|
},
|
||||||
|
endeffect: function(element) {
|
||||||
|
new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0});
|
||||||
|
},
|
||||||
|
zindex: 1000,
|
||||||
|
revert: false
|
||||||
|
}, arguments[1] || {});
|
||||||
|
|
||||||
|
this.element = $(element);
|
||||||
|
this.handle = options.handle ? $(options.handle) : this.element;
|
||||||
|
|
||||||
|
Element.makePositioned(this.element); // fix IE
|
||||||
|
|
||||||
|
this.offsetX = 0;
|
||||||
|
this.offsetY = 0;
|
||||||
|
this.originalLeft = this.currentLeft();
|
||||||
|
this.originalTop = this.currentTop();
|
||||||
|
this.originalX = this.element.offsetLeft;
|
||||||
|
this.originalY = this.element.offsetTop;
|
||||||
|
this.originalZ = parseInt(this.element.style.zIndex || "0");
|
||||||
|
|
||||||
|
this.options = options;
|
||||||
|
|
||||||
|
this.active = false;
|
||||||
|
this.dragging = false;
|
||||||
|
|
||||||
|
this.eventMouseDown = this.startDrag.bindAsEventListener(this);
|
||||||
|
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
|
||||||
|
this.eventMouseMove = this.update.bindAsEventListener(this);
|
||||||
|
this.eventKeypress = this.keyPress.bindAsEventListener(this);
|
||||||
|
|
||||||
|
Event.observe(this.handle, "mousedown", this.eventMouseDown);
|
||||||
|
Event.observe(document, "mouseup", this.eventMouseUp);
|
||||||
|
Event.observe(document, "mousemove", this.eventMouseMove);
|
||||||
|
Event.observe(document, "keypress", this.eventKeypress);
|
||||||
|
},
|
||||||
|
destroy: function() {
|
||||||
|
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
|
||||||
|
Event.stopObserving(document, "mouseup", this.eventMouseUp);
|
||||||
|
Event.stopObserving(document, "mousemove", this.eventMouseMove);
|
||||||
|
Event.stopObserving(document, "keypress", this.eventKeypress);
|
||||||
|
},
|
||||||
|
currentLeft: function() {
|
||||||
|
return parseInt(this.element.style.left || '0');
|
||||||
|
},
|
||||||
|
currentTop: function() {
|
||||||
|
return parseInt(this.element.style.top || '0')
|
||||||
|
},
|
||||||
|
startDrag: function(event) {
|
||||||
|
if(Event.isLeftClick(event)) {
|
||||||
|
this.active = true;
|
||||||
|
|
||||||
|
var style = this.element.style;
|
||||||
|
this.originalY = this.element.offsetTop - this.currentTop() - this.originalTop;
|
||||||
|
this.originalX = this.element.offsetLeft - this.currentLeft() - this.originalLeft;
|
||||||
|
this.offsetY = event.clientY - this.originalY - this.originalTop;
|
||||||
|
this.offsetX = event.clientX - this.originalX - this.originalLeft;
|
||||||
|
|
||||||
|
Event.stop(event);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
finishDrag: function(event, success) {
|
||||||
|
this.active = false;
|
||||||
|
this.dragging = false;
|
||||||
|
|
||||||
|
if(success) Droppables.fire(event, this.element);
|
||||||
|
Draggables.notify('onEnd', this);
|
||||||
|
|
||||||
|
var revert = this.options.revert;
|
||||||
|
if(revert && typeof revert == 'function') revert = revert(this.element);
|
||||||
|
|
||||||
|
if(revert && this.options.reverteffect) {
|
||||||
|
this.options.reverteffect(this.element,
|
||||||
|
this.currentTop()-this.originalTop,
|
||||||
|
this.currentLeft()-this.originalLeft);
|
||||||
|
} else {
|
||||||
|
this.originalLeft = this.currentLeft();
|
||||||
|
this.originalTop = this.currentTop();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.element.style.zIndex = this.originalZ;
|
||||||
|
|
||||||
|
if(this.options.endeffect)
|
||||||
|
this.options.endeffect(this.element);
|
||||||
|
|
||||||
|
Droppables.reset();
|
||||||
|
},
|
||||||
|
keyPress: function(event) {
|
||||||
|
if(this.active) {
|
||||||
|
if(event.keyCode==Event.KEY_ESC) {
|
||||||
|
this.finishDrag(event, false);
|
||||||
|
Event.stop(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
endDrag: function(event) {
|
||||||
|
if(this.active && this.dragging) {
|
||||||
|
this.finishDrag(event, true);
|
||||||
|
Event.stop(event);
|
||||||
|
}
|
||||||
|
this.active = false;
|
||||||
|
this.dragging = false;
|
||||||
|
},
|
||||||
|
draw: function(event) {
|
||||||
|
var style = this.element.style;
|
||||||
|
this.originalX = this.element.offsetLeft - this.currentLeft() - this.originalLeft;
|
||||||
|
this.originalY = this.element.offsetTop - this.currentTop() - this.originalTop;
|
||||||
|
if((!this.options.constraint) || (this.options.constraint=='horizontal'))
|
||||||
|
style.left = ((event.clientX - this.originalX) - this.offsetX) + "px";
|
||||||
|
if((!this.options.constraint) || (this.options.constraint=='vertical'))
|
||||||
|
style.top = ((event.clientY - this.originalY) - this.offsetY) + "px";
|
||||||
|
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
|
||||||
|
},
|
||||||
|
update: function(event) {
|
||||||
|
if(this.active) {
|
||||||
|
if(!this.dragging) {
|
||||||
|
var style = this.element.style;
|
||||||
|
this.dragging = true;
|
||||||
|
if(style.position=="") style.position = "relative";
|
||||||
|
style.zIndex = this.options.zindex;
|
||||||
|
Draggables.notify('onStart', this);
|
||||||
|
if(this.options.starteffect) this.options.starteffect(this.element);
|
||||||
|
}
|
||||||
|
|
||||||
|
Droppables.show(event, this.element);
|
||||||
|
this.draw(event);
|
||||||
|
if(this.options.change) this.options.change(this);
|
||||||
|
|
||||||
|
// fix AppleWebKit rendering
|
||||||
|
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
|
||||||
|
|
||||||
|
Event.stop(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
SortableObserver = Class.create();
|
||||||
|
SortableObserver.prototype = {
|
||||||
|
initialize: function(element, observer) {
|
||||||
|
this.element = $(element);
|
||||||
|
this.observer = observer;
|
||||||
|
this.lastValue = Sortable.serialize(this.element);
|
||||||
|
},
|
||||||
|
onStart: function() {
|
||||||
|
this.lastValue = Sortable.serialize(this.element);
|
||||||
|
},
|
||||||
|
onEnd: function() {
|
||||||
|
if(this.lastValue != Sortable.serialize(this.element))
|
||||||
|
this.observer(this.element)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Sortable = {
|
||||||
|
sortables: new Array(),
|
||||||
|
options: function(element){
|
||||||
|
var element = $(element);
|
||||||
|
for(var i=0;i<this.sortables.length;i++)
|
||||||
|
if(this.sortables[i].element == element)
|
||||||
|
return this.sortables[i];
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
destroy: function(element){
|
||||||
|
var element = $(element);
|
||||||
|
for(var i=0;i<this.sortables.length;i++) {
|
||||||
|
if(this.sortables[i].element == element) {
|
||||||
|
var s = this.sortables[i];
|
||||||
|
Draggables.removeObserver(s.element);
|
||||||
|
for(var j=0;j<s.droppables.length;j++)
|
||||||
|
Droppables.remove(s.droppables[j]);
|
||||||
|
for(var j=0;j<s.draggables.length;j++)
|
||||||
|
s.draggables[j].destroy();
|
||||||
|
this.sortables.splice(i,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
create: function(element) {
|
||||||
|
var element = $(element);
|
||||||
|
var options = Object.extend({
|
||||||
|
element: element,
|
||||||
|
tag: 'li', // assumes li children, override with tag: 'tagname'
|
||||||
|
overlap: 'vertical', // one of 'vertical', 'horizontal'
|
||||||
|
constraint: 'vertical', // one of 'vertical', 'horizontal', false
|
||||||
|
containment: element, // also takes array of elements (or id's); or false
|
||||||
|
handle: false, // or a CSS class
|
||||||
|
only: false,
|
||||||
|
hoverclass: null,
|
||||||
|
onChange: function() {},
|
||||||
|
onUpdate: function() {}
|
||||||
|
}, arguments[1] || {});
|
||||||
|
|
||||||
|
// clear any old sortable with same element
|
||||||
|
this.destroy(element);
|
||||||
|
|
||||||
|
// build options for the draggables
|
||||||
|
var options_for_draggable = {
|
||||||
|
revert: true,
|
||||||
|
constraint: options.constraint,
|
||||||
|
handle: handle };
|
||||||
|
if(options.starteffect)
|
||||||
|
options_for_draggable.starteffect = options.starteffect;
|
||||||
|
if(options.reverteffect)
|
||||||
|
options_for_draggable.reverteffect = options.reverteffect;
|
||||||
|
if(options.endeffect)
|
||||||
|
options_for_draggable.endeffect = options.endeffect;
|
||||||
|
if(options.zindex)
|
||||||
|
options_for_draggable.zindex = options.zindex;
|
||||||
|
|
||||||
|
// build options for the droppables
|
||||||
|
var options_for_droppable = {
|
||||||
|
overlap: options.overlap,
|
||||||
|
containment: options.containment,
|
||||||
|
hoverclass: options.hoverclass,
|
||||||
|
onHover: function(element, dropon, overlap) {
|
||||||
|
if(overlap>0.5) {
|
||||||
|
if(dropon.previousSibling != element) {
|
||||||
|
var oldParentNode = element.parentNode;
|
||||||
|
element.style.visibility = "hidden"; // fix gecko rendering
|
||||||
|
dropon.parentNode.insertBefore(element, dropon);
|
||||||
|
if(dropon.parentNode!=oldParentNode && oldParentNode.sortable)
|
||||||
|
oldParentNode.sortable.onChange(element);
|
||||||
|
if(dropon.parentNode.sortable)
|
||||||
|
dropon.parentNode.sortable.onChange(element);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var nextElement = dropon.nextSibling || null;
|
||||||
|
if(nextElement != element) {
|
||||||
|
var oldParentNode = element.parentNode;
|
||||||
|
element.style.visibility = "hidden"; // fix gecko rendering
|
||||||
|
dropon.parentNode.insertBefore(element, nextElement);
|
||||||
|
if(dropon.parentNode!=oldParentNode && oldParentNode.sortable)
|
||||||
|
oldParentNode.sortable.onChange(element);
|
||||||
|
if(dropon.parentNode.sortable)
|
||||||
|
dropon.parentNode.sortable.onChange(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix for gecko engine
|
||||||
|
Element.cleanWhitespace(element);
|
||||||
|
|
||||||
|
options.draggables = [];
|
||||||
|
options.droppables = [];
|
||||||
|
|
||||||
|
// make it so
|
||||||
|
var elements = element.childNodes;
|
||||||
|
for (var i = 0; i < elements.length; i++)
|
||||||
|
if(elements[i].tagName && elements[i].tagName==options.tag.toUpperCase() &&
|
||||||
|
(!options.only || (Element.Class.has(elements[i], options.only)))) {
|
||||||
|
|
||||||
|
// handles are per-draggable
|
||||||
|
var handle = options.handle ?
|
||||||
|
Element.Class.childrenWith(elements[i], options.handle)[0] : elements[i];
|
||||||
|
|
||||||
|
options.draggables.push(new Draggable(elements[i], Object.extend(options_for_draggable, { handle: handle })));
|
||||||
|
|
||||||
|
Droppables.add(elements[i], options_for_droppable);
|
||||||
|
options.droppables.push(elements[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// keep reference
|
||||||
|
this.sortables.push(options);
|
||||||
|
|
||||||
|
// for onupdate
|
||||||
|
Draggables.addObserver(new SortableObserver(element, options.onUpdate));
|
||||||
|
|
||||||
|
},
|
||||||
|
serialize: function(element) {
|
||||||
|
var element = $(element);
|
||||||
|
var sortableOptions = this.options(element);
|
||||||
|
var options = Object.extend({
|
||||||
|
tag: sortableOptions.tag,
|
||||||
|
only: sortableOptions.only,
|
||||||
|
name: element.id
|
||||||
|
}, arguments[1] || {});
|
||||||
|
|
||||||
|
var items = $(element).childNodes;
|
||||||
|
var queryComponents = new Array();
|
||||||
|
|
||||||
|
for(var i=0; i<items.length; i++)
|
||||||
|
if(items[i].tagName && items[i].tagName==options.tag.toUpperCase() &&
|
||||||
|
(!options.only || (Element.Class.has(items[i], options.only))))
|
||||||
|
queryComponents.push(
|
||||||
|
encodeURIComponent(options.name) + "[]=" +
|
||||||
|
encodeURIComponent(items[i].id.split("_")[1]));
|
||||||
|
|
||||||
|
return queryComponents.join("&");
|
||||||
|
}
|
||||||
|
}
|
612
public/javascripts/effects.js
vendored
Normal file
612
public/javascripts/effects.js
vendored
Normal file
|
@ -0,0 +1,612 @@
|
||||||
|
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
|
//
|
||||||
|
// Parts (c) 2005 Justin Palmer (http://encytemedia.com/)
|
||||||
|
// Parts (c) 2005 Mark Pilgrim (http://diveintomark.org/)
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
// a copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
Effect = {}
|
||||||
|
Effect2 = Effect; // deprecated
|
||||||
|
|
||||||
|
/* ------------- transitions ------------- */
|
||||||
|
|
||||||
|
Effect.Transitions = {}
|
||||||
|
|
||||||
|
Effect.Transitions.linear = function(pos) {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
Effect.Transitions.sinoidal = function(pos) {
|
||||||
|
return (-Math.cos(pos*Math.PI)/2) + 0.5;
|
||||||
|
}
|
||||||
|
Effect.Transitions.reverse = function(pos) {
|
||||||
|
return 1-pos;
|
||||||
|
}
|
||||||
|
Effect.Transitions.flicker = function(pos) {
|
||||||
|
return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random(0.25);
|
||||||
|
}
|
||||||
|
Effect.Transitions.wobble = function(pos) {
|
||||||
|
return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
|
||||||
|
}
|
||||||
|
Effect.Transitions.pulse = function(pos) {
|
||||||
|
return (Math.floor(pos*10) % 2 == 0 ?
|
||||||
|
(pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10)));
|
||||||
|
}
|
||||||
|
Effect.Transitions.none = function(pos) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Effect.Transitions.full = function(pos) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------- element ext -------------- */
|
||||||
|
|
||||||
|
Element.makePositioned = function(element) {
|
||||||
|
element = $(element);
|
||||||
|
if(element.style.position == "")
|
||||||
|
element.style.position = "relative";
|
||||||
|
}
|
||||||
|
|
||||||
|
Element.makeClipping = function(element) {
|
||||||
|
element = $(element);
|
||||||
|
element._overflow = element.style.overflow || 'visible';
|
||||||
|
if(element._overflow!='hidden') element.style.overflow = 'hidden';
|
||||||
|
}
|
||||||
|
|
||||||
|
Element.undoClipping = function(element) {
|
||||||
|
element = $(element);
|
||||||
|
if(element._overflow!='hidden') element.style.overflow = element._overflow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------- core effects ------------- */
|
||||||
|
|
||||||
|
Effect.Base = function() {};
|
||||||
|
Effect.Base.prototype = {
|
||||||
|
setOptions: function(options) {
|
||||||
|
this.options = Object.extend({
|
||||||
|
transition: Effect.Transitions.sinoidal,
|
||||||
|
duration: 1.0, // seconds
|
||||||
|
fps: 25.0, // max. 100fps
|
||||||
|
sync: false, // true for combining
|
||||||
|
from: 0.0,
|
||||||
|
to: 1.0
|
||||||
|
}, options || {});
|
||||||
|
},
|
||||||
|
start: function(options) {
|
||||||
|
this.setOptions(options || {});
|
||||||
|
this.currentFrame = 0;
|
||||||
|
this.startOn = new Date().getTime();
|
||||||
|
this.finishOn = this.startOn + (this.options.duration*1000);
|
||||||
|
if(this.options.beforeStart) this.options.beforeStart(this);
|
||||||
|
if(!this.options.sync) this.loop();
|
||||||
|
},
|
||||||
|
loop: function() {
|
||||||
|
var timePos = new Date().getTime();
|
||||||
|
if(timePos >= this.finishOn) {
|
||||||
|
this.render(this.options.to);
|
||||||
|
if(this.finish) this.finish();
|
||||||
|
if(this.options.afterFinish) this.options.afterFinish(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var pos = (timePos - this.startOn) / (this.finishOn - this.startOn);
|
||||||
|
var frame = Math.round(pos * this.options.fps * this.options.duration);
|
||||||
|
if(frame > this.currentFrame) {
|
||||||
|
this.render(pos);
|
||||||
|
this.currentFrame = frame;
|
||||||
|
}
|
||||||
|
this.timeout = setTimeout(this.loop.bind(this), 10);
|
||||||
|
},
|
||||||
|
render: function(pos) {
|
||||||
|
if(this.options.transition) pos = this.options.transition(pos);
|
||||||
|
pos *= (this.options.to-this.options.from);
|
||||||
|
pos += this.options.from;
|
||||||
|
if(this.options.beforeUpdate) this.options.beforeUpdate(this);
|
||||||
|
if(this.update) this.update(pos);
|
||||||
|
if(this.options.afterUpdate) this.options.afterUpdate(this);
|
||||||
|
},
|
||||||
|
cancel: function() {
|
||||||
|
if(this.timeout) clearTimeout(this.timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.Parallel = Class.create();
|
||||||
|
Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
|
||||||
|
initialize: function(effects) {
|
||||||
|
this.effects = effects || [];
|
||||||
|
this.start(arguments[1]);
|
||||||
|
},
|
||||||
|
update: function(position) {
|
||||||
|
for (var i = 0; i < this.effects.length; i++)
|
||||||
|
this.effects[i].render(position);
|
||||||
|
},
|
||||||
|
finish: function(position) {
|
||||||
|
for (var i = 0; i < this.effects.length; i++)
|
||||||
|
if(this.effects[i].finish) this.effects[i].finish(position);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Internet Explorer caveat: works only on elements the have
|
||||||
|
// a 'layout', meaning having a given width or height.
|
||||||
|
// There is no way to safely set this automatically.
|
||||||
|
Effect.Opacity = Class.create();
|
||||||
|
Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
|
||||||
|
initialize: function(element) {
|
||||||
|
this.element = $(element);
|
||||||
|
options = Object.extend({
|
||||||
|
from: 0.0,
|
||||||
|
to: 1.0
|
||||||
|
}, arguments[1] || {});
|
||||||
|
this.start(options);
|
||||||
|
},
|
||||||
|
update: function(position) {
|
||||||
|
this.setOpacity(position);
|
||||||
|
},
|
||||||
|
setOpacity: function(opacity) {
|
||||||
|
opacity = (opacity == 1) ? 0.99999 : opacity;
|
||||||
|
this.element.style.opacity = opacity;
|
||||||
|
this.element.style.filter = "alpha(opacity:"+opacity*100+")";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.MoveBy = Class.create();
|
||||||
|
Object.extend(Object.extend(Effect.MoveBy.prototype, Effect.Base.prototype), {
|
||||||
|
initialize: function(element, toTop, toLeft) {
|
||||||
|
this.element = $(element);
|
||||||
|
this.originalTop = parseFloat(this.element.style.top || '0');
|
||||||
|
this.originalLeft = parseFloat(this.element.style.left || '0');
|
||||||
|
this.toTop = toTop;
|
||||||
|
this.toLeft = toLeft;
|
||||||
|
Element.makePositioned(this.element);
|
||||||
|
this.start(arguments[3]);
|
||||||
|
},
|
||||||
|
update: function(position) {
|
||||||
|
topd = this.toTop * position + this.originalTop;
|
||||||
|
leftd = this.toLeft * position + this.originalLeft;
|
||||||
|
this.setPosition(topd, leftd);
|
||||||
|
},
|
||||||
|
setPosition: function(topd, leftd) {
|
||||||
|
this.element.style.top = topd + "px";
|
||||||
|
this.element.style.left = leftd + "px";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.Scale = Class.create();
|
||||||
|
Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
|
||||||
|
initialize: function(element, percent) {
|
||||||
|
this.element = $(element)
|
||||||
|
options = Object.extend({
|
||||||
|
scaleX: true,
|
||||||
|
scaleY: true,
|
||||||
|
scaleContent: true,
|
||||||
|
scaleFromCenter: false,
|
||||||
|
scaleMode: 'box', // 'box' or 'contents' or {} with provided values
|
||||||
|
scaleFrom: 100.0
|
||||||
|
}, arguments[2] || {});
|
||||||
|
this.originalTop = this.element.offsetTop;
|
||||||
|
this.originalLeft = this.element.offsetLeft;
|
||||||
|
if(this.element.style.fontSize=="") this.sizeEm = 1.0;
|
||||||
|
if(this.element.style.fontSize && this.element.style.fontSize.indexOf("em")>0)
|
||||||
|
this.sizeEm = parseFloat(this.element.style.fontSize);
|
||||||
|
this.factor = (percent/100.0) - (options.scaleFrom/100.0);
|
||||||
|
if(options.scaleMode=='box') {
|
||||||
|
this.originalHeight = this.element.clientHeight;
|
||||||
|
this.originalWidth = this.element.clientWidth;
|
||||||
|
} else
|
||||||
|
if(options.scaleMode=='contents') {
|
||||||
|
this.originalHeight = this.element.scrollHeight;
|
||||||
|
this.originalWidth = this.element.scrollWidth;
|
||||||
|
} else {
|
||||||
|
this.originalHeight = options.scaleMode.originalHeight;
|
||||||
|
this.originalWidth = options.scaleMode.originalWidth;
|
||||||
|
}
|
||||||
|
this.start(options);
|
||||||
|
},
|
||||||
|
|
||||||
|
update: function(position) {
|
||||||
|
currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
|
||||||
|
if(this.options.scaleContent && this.sizeEm)
|
||||||
|
this.element.style.fontSize = this.sizeEm*currentScale + "em";
|
||||||
|
this.setDimensions(
|
||||||
|
this.originalWidth * currentScale,
|
||||||
|
this.originalHeight * currentScale);
|
||||||
|
},
|
||||||
|
|
||||||
|
setDimensions: function(width, height) {
|
||||||
|
if(this.options.scaleX) this.element.style.width = width + 'px';
|
||||||
|
if(this.options.scaleY) this.element.style.height = height + 'px';
|
||||||
|
if(this.options.scaleFromCenter) {
|
||||||
|
topd = (height - this.originalHeight)/2;
|
||||||
|
leftd = (width - this.originalWidth)/2;
|
||||||
|
if(this.element.style.position=='absolute') {
|
||||||
|
if(this.options.scaleY) this.element.style.top = this.originalTop-topd + "px";
|
||||||
|
if(this.options.scaleX) this.element.style.left = this.originalLeft-leftd + "px";
|
||||||
|
} else {
|
||||||
|
if(this.options.scaleY) this.element.style.top = -topd + "px";
|
||||||
|
if(this.options.scaleX) this.element.style.left = -leftd + "px";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.Highlight = Class.create();
|
||||||
|
Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
|
||||||
|
initialize: function(element) {
|
||||||
|
this.element = $(element);
|
||||||
|
|
||||||
|
// try to parse current background color as default for endcolor
|
||||||
|
// browser stores this as: "rgb(255, 255, 255)", convert to "#ffffff" format
|
||||||
|
var endcolor = "#ffffff";
|
||||||
|
var current = this.element.style.backgroundColor;
|
||||||
|
if(current && current.slice(0,4) == "rgb(") {
|
||||||
|
endcolor = "#";
|
||||||
|
var cols = current.slice(4,current.length-1).split(',');
|
||||||
|
var i=0; do { endcolor += parseInt(cols[i]).toColorPart() } while (++i<3); }
|
||||||
|
|
||||||
|
var options = Object.extend({
|
||||||
|
startcolor: "#ffff99",
|
||||||
|
endcolor: endcolor,
|
||||||
|
restorecolor: current
|
||||||
|
}, arguments[1] || {});
|
||||||
|
|
||||||
|
// init color calculations
|
||||||
|
this.colors_base = [
|
||||||
|
parseInt(options.startcolor.slice(1,3),16),
|
||||||
|
parseInt(options.startcolor.slice(3,5),16),
|
||||||
|
parseInt(options.startcolor.slice(5),16) ];
|
||||||
|
this.colors_delta = [
|
||||||
|
parseInt(options.endcolor.slice(1,3),16)-this.colors_base[0],
|
||||||
|
parseInt(options.endcolor.slice(3,5),16)-this.colors_base[1],
|
||||||
|
parseInt(options.endcolor.slice(5),16)-this.colors_base[2] ];
|
||||||
|
|
||||||
|
this.start(options);
|
||||||
|
},
|
||||||
|
update: function(position) {
|
||||||
|
var colors = [
|
||||||
|
Math.round(this.colors_base[0]+(this.colors_delta[0]*position)),
|
||||||
|
Math.round(this.colors_base[1]+(this.colors_delta[1]*position)),
|
||||||
|
Math.round(this.colors_base[2]+(this.colors_delta[2]*position)) ];
|
||||||
|
this.element.style.backgroundColor = "#" +
|
||||||
|
colors[0].toColorPart() + colors[1].toColorPart() + colors[2].toColorPart();
|
||||||
|
},
|
||||||
|
finish: function() {
|
||||||
|
this.element.style.backgroundColor = this.options.restorecolor;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.ScrollTo = Class.create();
|
||||||
|
Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
|
||||||
|
initialize: function(element) {
|
||||||
|
this.element = $(element);
|
||||||
|
Position.prepare();
|
||||||
|
var offsets = Position.cumulativeOffset(this.element);
|
||||||
|
var max = window.innerHeight ?
|
||||||
|
window.height - window.innerHeight :
|
||||||
|
document.body.scrollHeight -
|
||||||
|
(document.documentElement.clientHeight ?
|
||||||
|
document.documentElement.clientHeight : document.body.clientHeight);
|
||||||
|
this.scrollStart = Position.deltaY;
|
||||||
|
this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
|
||||||
|
this.start(arguments[1] || {});
|
||||||
|
},
|
||||||
|
update: function(position) {
|
||||||
|
Position.prepare();
|
||||||
|
window.scrollTo(Position.deltaX,
|
||||||
|
this.scrollStart + (position*this.delta));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/* ------------- prepackaged effects ------------- */
|
||||||
|
|
||||||
|
Effect.Fade = function(element) {
|
||||||
|
options = Object.extend({
|
||||||
|
from: 1.0,
|
||||||
|
to: 0.0,
|
||||||
|
afterFinish: function(effect)
|
||||||
|
{ Element.hide(effect.element);
|
||||||
|
effect.setOpacity(1); }
|
||||||
|
}, arguments[1] || {});
|
||||||
|
new Effect.Opacity(element,options);
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.Appear = function(element) {
|
||||||
|
options = Object.extend({
|
||||||
|
from: 0.0,
|
||||||
|
to: 1.0,
|
||||||
|
beforeStart: function(effect)
|
||||||
|
{ effect.setOpacity(0);
|
||||||
|
Element.show(effect.element); },
|
||||||
|
afterUpdate: function(effect)
|
||||||
|
{ Element.show(effect.element); }
|
||||||
|
}, arguments[1] || {});
|
||||||
|
new Effect.Opacity(element,options);
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.Puff = function(element) {
|
||||||
|
new Effect.Parallel(
|
||||||
|
[ new Effect.Scale(element, 200, { sync: true, scaleFromCenter: true }),
|
||||||
|
new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0 } ) ],
|
||||||
|
{ duration: 1.0,
|
||||||
|
afterUpdate: function(effect)
|
||||||
|
{ effect.effects[0].element.style.position = 'absolute'; },
|
||||||
|
afterFinish: function(effect)
|
||||||
|
{ Element.hide(effect.effects[0].element); }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.BlindUp = function(element) {
|
||||||
|
Element.makeClipping(element);
|
||||||
|
new Effect.Scale(element, 0,
|
||||||
|
Object.extend({ scaleContent: false,
|
||||||
|
scaleX: false,
|
||||||
|
afterFinish: function(effect)
|
||||||
|
{
|
||||||
|
Element.hide(effect.element);
|
||||||
|
Element.undoClipping(effect.element);
|
||||||
|
}
|
||||||
|
}, arguments[1] || {})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.BlindDown = function(element) {
|
||||||
|
$(element).style.height = '0px';
|
||||||
|
Element.makeClipping(element);
|
||||||
|
Element.show(element);
|
||||||
|
new Effect.Scale(element, 100,
|
||||||
|
Object.extend({ scaleContent: false,
|
||||||
|
scaleX: false,
|
||||||
|
scaleMode: 'contents',
|
||||||
|
scaleFrom: 0,
|
||||||
|
afterFinish: function(effect) {
|
||||||
|
Element.undoClipping(effect.element);
|
||||||
|
}
|
||||||
|
}, arguments[1] || {})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.SwitchOff = function(element) {
|
||||||
|
new Effect.Appear(element,
|
||||||
|
{ duration: 0.4,
|
||||||
|
transition: Effect.Transitions.flicker,
|
||||||
|
afterFinish: function(effect)
|
||||||
|
{ effect.element.style.overflow = 'hidden';
|
||||||
|
new Effect.Scale(effect.element, 1,
|
||||||
|
{ duration: 0.3, scaleFromCenter: true,
|
||||||
|
scaleX: false, scaleContent: false,
|
||||||
|
afterUpdate: function(effect) {
|
||||||
|
if(effect.element.style.position=="")
|
||||||
|
effect.element.style.position = 'relative'; },
|
||||||
|
afterFinish: function(effect) { Element.hide(effect.element); }
|
||||||
|
} )
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.DropOut = function(element) {
|
||||||
|
new Effect.Parallel(
|
||||||
|
[ new Effect.MoveBy(element, 100, 0, { sync: true }),
|
||||||
|
new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0 } ) ],
|
||||||
|
{ duration: 0.5,
|
||||||
|
afterFinish: function(effect)
|
||||||
|
{ Element.hide(effect.effects[0].element); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.Shake = function(element) {
|
||||||
|
new Effect.MoveBy(element, 0, 20,
|
||||||
|
{ duration: 0.05, afterFinish: function(effect) {
|
||||||
|
new Effect.MoveBy(effect.element, 0, -40,
|
||||||
|
{ duration: 0.1, afterFinish: function(effect) {
|
||||||
|
new Effect.MoveBy(effect.element, 0, 40,
|
||||||
|
{ duration: 0.1, afterFinish: function(effect) {
|
||||||
|
new Effect.MoveBy(effect.element, 0, -40,
|
||||||
|
{ duration: 0.1, afterFinish: function(effect) {
|
||||||
|
new Effect.MoveBy(effect.element, 0, 40,
|
||||||
|
{ duration: 0.1, afterFinish: function(effect) {
|
||||||
|
new Effect.MoveBy(effect.element, 0, -20,
|
||||||
|
{ duration: 0.05, afterFinish: function(effect) {
|
||||||
|
}}) }}) }}) }}) }}) }});
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.SlideDown = function(element) {
|
||||||
|
element = $(element);
|
||||||
|
element.style.height = '0px';
|
||||||
|
Element.makeClipping(element);
|
||||||
|
Element.cleanWhitespace(element);
|
||||||
|
Element.makePositioned(element.firstChild);
|
||||||
|
Element.show(element);
|
||||||
|
new Effect.Scale(element, 100,
|
||||||
|
Object.extend({ scaleContent: false,
|
||||||
|
scaleX: false,
|
||||||
|
scaleMode: 'contents',
|
||||||
|
scaleFrom: 0,
|
||||||
|
afterUpdate: function(effect)
|
||||||
|
{ effect.element.firstChild.style.bottom =
|
||||||
|
(effect.originalHeight - effect.element.clientHeight) + 'px'; },
|
||||||
|
afterFinish: function(effect)
|
||||||
|
{ Element.undoClipping(effect.element); }
|
||||||
|
}, arguments[1] || {})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.SlideUp = function(element) {
|
||||||
|
element = $(element);
|
||||||
|
Element.makeClipping(element);
|
||||||
|
Element.cleanWhitespace(element);
|
||||||
|
Element.makePositioned(element.firstChild);
|
||||||
|
Element.show(element);
|
||||||
|
new Effect.Scale(element, 0,
|
||||||
|
Object.extend({ scaleContent: false,
|
||||||
|
scaleX: false,
|
||||||
|
afterUpdate: function(effect)
|
||||||
|
{ effect.element.firstChild.style.bottom =
|
||||||
|
(effect.originalHeight - effect.element.clientHeight) + 'px'; },
|
||||||
|
afterFinish: function(effect)
|
||||||
|
{
|
||||||
|
Element.hide(effect.element);
|
||||||
|
Element.undoClipping(effect.element);
|
||||||
|
}
|
||||||
|
}, arguments[1] || {})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.Squish = function(element) {
|
||||||
|
new Effect.Scale(element, 0,
|
||||||
|
{ afterFinish: function(effect) { Element.hide(effect.element); } });
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.Grow = function(element) {
|
||||||
|
element = $(element);
|
||||||
|
var options = arguments[1] || {};
|
||||||
|
|
||||||
|
var originalWidth = element.clientWidth;
|
||||||
|
var originalHeight = element.clientHeight;
|
||||||
|
element.style.overflow = 'hidden';
|
||||||
|
Element.show(element);
|
||||||
|
|
||||||
|
var direction = options.direction || 'center';
|
||||||
|
var moveTransition = options.moveTransition || Effect.Transitions.sinoidal;
|
||||||
|
var scaleTransition = options.scaleTransition || Effect.Transitions.sinoidal;
|
||||||
|
var opacityTransition = options.opacityTransition || Effect.Transitions.full;
|
||||||
|
|
||||||
|
var initialMoveX, initialMoveY;
|
||||||
|
var moveX, moveY;
|
||||||
|
|
||||||
|
switch (direction) {
|
||||||
|
case 'top-left':
|
||||||
|
initialMoveX = initialMoveY = moveX = moveY = 0;
|
||||||
|
break;
|
||||||
|
case 'top-right':
|
||||||
|
initialMoveX = originalWidth;
|
||||||
|
initialMoveY = moveY = 0;
|
||||||
|
moveX = -originalWidth;
|
||||||
|
break;
|
||||||
|
case 'bottom-left':
|
||||||
|
initialMoveX = moveX = 0;
|
||||||
|
initialMoveY = originalHeight;
|
||||||
|
moveY = -originalHeight;
|
||||||
|
break;
|
||||||
|
case 'bottom-right':
|
||||||
|
initialMoveX = originalWidth;
|
||||||
|
initialMoveY = originalHeight;
|
||||||
|
moveX = -originalWidth;
|
||||||
|
moveY = -originalHeight;
|
||||||
|
break;
|
||||||
|
case 'center':
|
||||||
|
initialMoveX = originalWidth / 2;
|
||||||
|
initialMoveY = originalHeight / 2;
|
||||||
|
moveX = -originalWidth / 2;
|
||||||
|
moveY = -originalHeight / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
new Effect.MoveBy(element, initialMoveY, initialMoveX, {
|
||||||
|
duration: 0.01,
|
||||||
|
beforeUpdate: function(effect) { $(element).style.height = '0px'; },
|
||||||
|
afterFinish: function(effect) {
|
||||||
|
new Effect.Parallel(
|
||||||
|
[ new Effect.Opacity(element, { sync: true, to: 1.0, from: 0.0, transition: opacityTransition }),
|
||||||
|
new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: moveTransition }),
|
||||||
|
new Effect.Scale(element, 100, {
|
||||||
|
scaleMode: { originalHeight: originalHeight, originalWidth: originalWidth },
|
||||||
|
sync: true, scaleFrom: 0, scaleTo: 100, transition: scaleTransition })],
|
||||||
|
options); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.Shrink = function(element) {
|
||||||
|
element = $(element);
|
||||||
|
var options = arguments[1] || {};
|
||||||
|
|
||||||
|
var originalWidth = element.clientWidth;
|
||||||
|
var originalHeight = element.clientHeight;
|
||||||
|
element.style.overflow = 'hidden';
|
||||||
|
Element.show(element);
|
||||||
|
|
||||||
|
var direction = options.direction || 'center';
|
||||||
|
var moveTransition = options.moveTransition || Effect.Transitions.sinoidal;
|
||||||
|
var scaleTransition = options.scaleTransition || Effect.Transitions.sinoidal;
|
||||||
|
var opacityTransition = options.opacityTransition || Effect.Transitions.none;
|
||||||
|
|
||||||
|
var moveX, moveY;
|
||||||
|
|
||||||
|
switch (direction) {
|
||||||
|
case 'top-left':
|
||||||
|
moveX = moveY = 0;
|
||||||
|
break;
|
||||||
|
case 'top-right':
|
||||||
|
moveX = originalWidth;
|
||||||
|
moveY = 0;
|
||||||
|
break;
|
||||||
|
case 'bottom-left':
|
||||||
|
moveX = 0;
|
||||||
|
moveY = originalHeight;
|
||||||
|
break;
|
||||||
|
case 'bottom-right':
|
||||||
|
moveX = originalWidth;
|
||||||
|
moveY = originalHeight;
|
||||||
|
break;
|
||||||
|
case 'center':
|
||||||
|
moveX = originalWidth / 2;
|
||||||
|
moveY = originalHeight / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
new Effect.Parallel(
|
||||||
|
[ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: opacityTransition }),
|
||||||
|
new Effect.Scale(element, 0, { sync: true, transition: moveTransition }),
|
||||||
|
new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: scaleTransition }) ],
|
||||||
|
options);
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.Pulsate = function(element) {
|
||||||
|
var options = arguments[1] || {};
|
||||||
|
var transition = options.transition || Effect.Transitions.sinoidal;
|
||||||
|
var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
|
||||||
|
reverser.bind(transition);
|
||||||
|
new Effect.Opacity(element,
|
||||||
|
Object.extend(Object.extend({ duration: 3.0,
|
||||||
|
afterFinish: function(effect) { Element.show(effect.element); }
|
||||||
|
}, options), {transition: reverser}));
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect.Fold = function(element) {
|
||||||
|
$(element).style.overflow = 'hidden';
|
||||||
|
new Effect.Scale(element, 5, Object.extend({
|
||||||
|
scaleContent: false,
|
||||||
|
scaleTo: 100,
|
||||||
|
scaleX: false,
|
||||||
|
afterFinish: function(effect) {
|
||||||
|
new Effect.Scale(element, 1, {
|
||||||
|
scaleContent: false,
|
||||||
|
scaleTo: 0,
|
||||||
|
scaleY: false,
|
||||||
|
afterFinish: function(effect) { Element.hide(effect.element) } });
|
||||||
|
}}, arguments[1] || {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// old: new Effect.ContentZoom(element, percent)
|
||||||
|
// new: Element.setContentZoom(element, percent)
|
||||||
|
|
||||||
|
Element.setContentZoom = function(element, percent) {
|
||||||
|
var element = $(element);
|
||||||
|
element.style.fontSize = (percent/100) + "em";
|
||||||
|
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
|
||||||
|
}
|
928
public/javascripts/prototype.js
vendored
928
public/javascripts/prototype.js
vendored
File diff suppressed because it is too large
Load diff
19
script/benchmarker
Executable file
19
script/benchmarker
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/ruby1.8
|
||||||
|
|
||||||
|
if ARGV.empty?
|
||||||
|
puts "Usage: benchmarker times 'Person.expensive_way' 'Person.another_expensive_way' ..."
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
require File.dirname(__FILE__) + '/../config/environment'
|
||||||
|
require 'benchmark'
|
||||||
|
include Benchmark
|
||||||
|
|
||||||
|
# Don't include compilation in the benchmark
|
||||||
|
ARGV[1..-1].each { |expression| eval(expression) }
|
||||||
|
|
||||||
|
bm(6) do |x|
|
||||||
|
ARGV[1..-1].each_with_index do |expression, idx|
|
||||||
|
x.report("##{idx + 1}") { ARGV[0].to_i.times { eval(expression) } }
|
||||||
|
end
|
||||||
|
end
|
7
script/destroy
Executable file
7
script/destroy
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/ruby1.8
|
||||||
|
require File.dirname(__FILE__) + '/../config/environment'
|
||||||
|
require 'rails_generator'
|
||||||
|
require 'rails_generator/scripts/destroy'
|
||||||
|
|
||||||
|
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
||||||
|
Rails::Generator::Scripts::Destroy.new.run(ARGV)
|
7
script/generate
Executable file
7
script/generate
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/ruby1.8
|
||||||
|
require File.dirname(__FILE__) + '/../config/environment'
|
||||||
|
require 'rails_generator'
|
||||||
|
require 'rails_generator/scripts/generate'
|
||||||
|
|
||||||
|
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
||||||
|
Rails::Generator::Scripts::Generate.new.run(ARGV)
|
34
script/profiler
Executable file
34
script/profiler
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/ruby1.8
|
||||||
|
if ARGV.empty?
|
||||||
|
$stderr.puts "Usage: profiler 'Person.expensive_method(10)' [times]"
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Keep the expensive require out of the profile.
|
||||||
|
$stderr.puts 'Loading Rails...'
|
||||||
|
require File.dirname(__FILE__) + '/../config/environment'
|
||||||
|
|
||||||
|
# Define a method to profile.
|
||||||
|
if ARGV[1] and ARGV[1].to_i > 1
|
||||||
|
eval "def profile_me() #{ARGV[1]}.times { #{ARGV[0]} } end"
|
||||||
|
else
|
||||||
|
eval "def profile_me() #{ARGV[0]} end"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Use the ruby-prof extension if available. Fall back to stdlib profiler.
|
||||||
|
begin
|
||||||
|
require 'prof'
|
||||||
|
$stderr.puts 'Using the ruby-prof extension.'
|
||||||
|
Prof.clock_mode = Prof::GETTIMEOFDAY
|
||||||
|
Prof.start
|
||||||
|
profile_me
|
||||||
|
results = Prof.stop
|
||||||
|
require 'rubyprof_ext'
|
||||||
|
Prof.print_profile(results, $stderr)
|
||||||
|
rescue LoadError
|
||||||
|
$stderr.puts 'Using the standard Ruby profiler.'
|
||||||
|
Profiler__.start_profile
|
||||||
|
profile_me
|
||||||
|
Profiler__.stop_profile
|
||||||
|
Profiler__.print_profile($stderr)
|
||||||
|
end
|
29
script/runner
Executable file
29
script/runner
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/ruby1.8
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
|
options = { :environment => "development" }
|
||||||
|
|
||||||
|
ARGV.options do |opts|
|
||||||
|
script_name = File.basename($0)
|
||||||
|
opts.banner = "Usage: runner 'puts Person.find(1).name' [options]"
|
||||||
|
|
||||||
|
opts.separator ""
|
||||||
|
|
||||||
|
opts.on("-e", "--environment=name", String,
|
||||||
|
"Specifies the environment for the runner to operate under (test/development/production).",
|
||||||
|
"Default: development") { |options[:environment]| }
|
||||||
|
|
||||||
|
opts.separator ""
|
||||||
|
|
||||||
|
opts.on("-h", "--help",
|
||||||
|
"Show this help message.") { puts opts; exit }
|
||||||
|
|
||||||
|
opts.parse!
|
||||||
|
end
|
||||||
|
|
||||||
|
ENV["RAILS_ENV"] = options[:environment]
|
||||||
|
|
||||||
|
#!/usr/local/bin/ruby
|
||||||
|
|
||||||
|
require File.dirname(__FILE__) + '/../config/environment'
|
||||||
|
eval(ARGV.first)
|
Loading…
Reference in a new issue