mirror of
https://github.com/redmine/redmine.git
synced 2026-03-06 12:31:40 +01:00
* added issue_relations branch
* issue_relation model added git-svn-id: http://redmine.rubyforge.org/svn/branches/work@162 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
19
issue_relations/public/javascripts/application.js
Normal file
19
issue_relations/public/javascripts/application.js
Normal file
@@ -0,0 +1,19 @@
|
||||
function checkAll (id, checked) {
|
||||
var el = document.getElementById(id);
|
||||
for (var i = 0; i < el.elements.length; i++) {
|
||||
if (el.elements[i].disabled==false) {
|
||||
el.elements[i].checked = checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addFileField() {
|
||||
var f = document.createElement("input");
|
||||
f.type = "file";
|
||||
f.name = "attachments[]";
|
||||
f.size = 30;
|
||||
|
||||
p = document.getElementById("attachments_p");
|
||||
p.appendChild(document.createElement("br"));
|
||||
p.appendChild(f);
|
||||
}
|
||||
200
issue_relations/public/javascripts/calendar/calendar-setup.js
Normal file
200
issue_relations/public/javascripts/calendar/calendar-setup.js
Normal file
@@ -0,0 +1,200 @@
|
||||
/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/
|
||||
* ---------------------------------------------------------------------------
|
||||
*
|
||||
* The DHTML Calendar
|
||||
*
|
||||
* Details and latest version at:
|
||||
* http://dynarch.com/mishoo/calendar.epl
|
||||
*
|
||||
* This script is distributed under the GNU Lesser General Public License.
|
||||
* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
|
||||
*
|
||||
* This file defines helper functions for setting up the calendar. They are
|
||||
* intended to help non-programmers get a working calendar on their site
|
||||
* quickly. This script should not be seen as part of the calendar. It just
|
||||
* shows you what one can do with the calendar, while in the same time
|
||||
* providing a quick and simple method for setting it up. If you need
|
||||
* exhaustive customization of the calendar creation process feel free to
|
||||
* modify this code to suit your needs (this is recommended and much better
|
||||
* than modifying calendar.js itself).
|
||||
*/
|
||||
|
||||
// $Id: calendar-setup.js,v 1.25 2005/03/07 09:51:33 mishoo Exp $
|
||||
|
||||
/**
|
||||
* This function "patches" an input field (or other element) to use a calendar
|
||||
* widget for date selection.
|
||||
*
|
||||
* The "params" is a single object that can have the following properties:
|
||||
*
|
||||
* prop. name | description
|
||||
* -------------------------------------------------------------------------------------------------
|
||||
* inputField | the ID of an input field to store the date
|
||||
* displayArea | the ID of a DIV or other element to show the date
|
||||
* button | ID of a button or other element that will trigger the calendar
|
||||
* eventName | event that will trigger the calendar, without the "on" prefix (default: "click")
|
||||
* ifFormat | date format that will be stored in the input field
|
||||
* daFormat | the date format that will be used to display the date in displayArea
|
||||
* singleClick | (true/false) wether the calendar is in single click mode or not (default: true)
|
||||
* firstDay | numeric: 0 to 6. "0" means display Sunday first, "1" means display Monday first, etc.
|
||||
* align | alignment (default: "Br"); if you don't know what's this see the calendar documentation
|
||||
* range | array with 2 elements. Default: [1900, 2999] -- the range of years available
|
||||
* weekNumbers | (true/false) if it's true (default) the calendar will display week numbers
|
||||
* flat | null or element ID; if not null the calendar will be a flat calendar having the parent with the given ID
|
||||
* flatCallback | function that receives a JS Date object and returns an URL to point the browser to (for flat calendar)
|
||||
* disableFunc | function that receives a JS Date object and should return true if that date has to be disabled in the calendar
|
||||
* onSelect | function that gets called when a date is selected. You don't _have_ to supply this (the default is generally okay)
|
||||
* onClose | function that gets called when the calendar is closed. [default]
|
||||
* onUpdate | function that gets called after the date is updated in the input field. Receives a reference to the calendar.
|
||||
* date | the date that the calendar will be initially displayed to
|
||||
* showsTime | default: false; if true the calendar will include a time selector
|
||||
* timeFormat | the time format; can be "12" or "24", default is "12"
|
||||
* electric | if true (default) then given fields/date areas are updated for each move; otherwise they're updated only on close
|
||||
* step | configures the step of the years in drop-down boxes; default: 2
|
||||
* position | configures the calendar absolute position; default: null
|
||||
* cache | if "true" (but default: "false") it will reuse the same calendar object, where possible
|
||||
* showOthers | if "true" (but default: "false") it will show days from other months too
|
||||
*
|
||||
* None of them is required, they all have default values. However, if you
|
||||
* pass none of "inputField", "displayArea" or "button" you'll get a warning
|
||||
* saying "nothing to setup".
|
||||
*/
|
||||
Calendar.setup = function (params) {
|
||||
function param_default(pname, def) { if (typeof params[pname] == "undefined") { params[pname] = def; } };
|
||||
|
||||
param_default("inputField", null);
|
||||
param_default("displayArea", null);
|
||||
param_default("button", null);
|
||||
param_default("eventName", "click");
|
||||
param_default("ifFormat", "%Y/%m/%d");
|
||||
param_default("daFormat", "%Y/%m/%d");
|
||||
param_default("singleClick", true);
|
||||
param_default("disableFunc", null);
|
||||
param_default("dateStatusFunc", params["disableFunc"]); // takes precedence if both are defined
|
||||
param_default("dateText", null);
|
||||
param_default("firstDay", null);
|
||||
param_default("align", "Br");
|
||||
param_default("range", [1900, 2999]);
|
||||
param_default("weekNumbers", true);
|
||||
param_default("flat", null);
|
||||
param_default("flatCallback", null);
|
||||
param_default("onSelect", null);
|
||||
param_default("onClose", null);
|
||||
param_default("onUpdate", null);
|
||||
param_default("date", null);
|
||||
param_default("showsTime", false);
|
||||
param_default("timeFormat", "24");
|
||||
param_default("electric", true);
|
||||
param_default("step", 2);
|
||||
param_default("position", null);
|
||||
param_default("cache", false);
|
||||
param_default("showOthers", false);
|
||||
param_default("multiple", null);
|
||||
|
||||
var tmp = ["inputField", "displayArea", "button"];
|
||||
for (var i in tmp) {
|
||||
if (typeof params[tmp[i]] == "string") {
|
||||
params[tmp[i]] = document.getElementById(params[tmp[i]]);
|
||||
}
|
||||
}
|
||||
if (!(params.flat || params.multiple || params.inputField || params.displayArea || params.button)) {
|
||||
alert("Calendar.setup:\n Nothing to setup (no fields found). Please check your code");
|
||||
return false;
|
||||
}
|
||||
|
||||
function onSelect(cal) {
|
||||
var p = cal.params;
|
||||
var update = (cal.dateClicked || p.electric);
|
||||
if (update && p.inputField) {
|
||||
p.inputField.value = cal.date.print(p.ifFormat);
|
||||
if (typeof p.inputField.onchange == "function")
|
||||
p.inputField.onchange();
|
||||
}
|
||||
if (update && p.displayArea)
|
||||
p.displayArea.innerHTML = cal.date.print(p.daFormat);
|
||||
if (update && typeof p.onUpdate == "function")
|
||||
p.onUpdate(cal);
|
||||
if (update && p.flat) {
|
||||
if (typeof p.flatCallback == "function")
|
||||
p.flatCallback(cal);
|
||||
}
|
||||
if (update && p.singleClick && cal.dateClicked)
|
||||
cal.callCloseHandler();
|
||||
};
|
||||
|
||||
if (params.flat != null) {
|
||||
if (typeof params.flat == "string")
|
||||
params.flat = document.getElementById(params.flat);
|
||||
if (!params.flat) {
|
||||
alert("Calendar.setup:\n Flat specified but can't find parent.");
|
||||
return false;
|
||||
}
|
||||
var cal = new Calendar(params.firstDay, params.date, params.onSelect || onSelect);
|
||||
cal.showsOtherMonths = params.showOthers;
|
||||
cal.showsTime = params.showsTime;
|
||||
cal.time24 = (params.timeFormat == "24");
|
||||
cal.params = params;
|
||||
cal.weekNumbers = params.weekNumbers;
|
||||
cal.setRange(params.range[0], params.range[1]);
|
||||
cal.setDateStatusHandler(params.dateStatusFunc);
|
||||
cal.getDateText = params.dateText;
|
||||
if (params.ifFormat) {
|
||||
cal.setDateFormat(params.ifFormat);
|
||||
}
|
||||
if (params.inputField && typeof params.inputField.value == "string") {
|
||||
cal.parseDate(params.inputField.value);
|
||||
}
|
||||
cal.create(params.flat);
|
||||
cal.show();
|
||||
return false;
|
||||
}
|
||||
|
||||
var triggerEl = params.button || params.displayArea || params.inputField;
|
||||
triggerEl["on" + params.eventName] = function() {
|
||||
var dateEl = params.inputField || params.displayArea;
|
||||
var dateFmt = params.inputField ? params.ifFormat : params.daFormat;
|
||||
var mustCreate = false;
|
||||
var cal = window.calendar;
|
||||
if (dateEl)
|
||||
params.date = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt);
|
||||
if (!(cal && params.cache)) {
|
||||
window.calendar = cal = new Calendar(params.firstDay,
|
||||
params.date,
|
||||
params.onSelect || onSelect,
|
||||
params.onClose || function(cal) { cal.hide(); });
|
||||
cal.showsTime = params.showsTime;
|
||||
cal.time24 = (params.timeFormat == "24");
|
||||
cal.weekNumbers = params.weekNumbers;
|
||||
mustCreate = true;
|
||||
} else {
|
||||
if (params.date)
|
||||
cal.setDate(params.date);
|
||||
cal.hide();
|
||||
}
|
||||
if (params.multiple) {
|
||||
cal.multiple = {};
|
||||
for (var i = params.multiple.length; --i >= 0;) {
|
||||
var d = params.multiple[i];
|
||||
var ds = d.print("%Y%m%d");
|
||||
cal.multiple[ds] = d;
|
||||
}
|
||||
}
|
||||
cal.showsOtherMonths = params.showOthers;
|
||||
cal.yearStep = params.step;
|
||||
cal.setRange(params.range[0], params.range[1]);
|
||||
cal.params = params;
|
||||
cal.setDateStatusHandler(params.dateStatusFunc);
|
||||
cal.getDateText = params.dateText;
|
||||
cal.setDateFormat(dateFmt);
|
||||
if (mustCreate)
|
||||
cal.create();
|
||||
cal.refresh();
|
||||
if (!params.position)
|
||||
cal.showAtElement(params.button || params.displayArea || params.inputField, params.align);
|
||||
else
|
||||
cal.showAt(params.position[0], params.position[1]);
|
||||
return false;
|
||||
};
|
||||
|
||||
return cal;
|
||||
};
|
||||
1806
issue_relations/public/javascripts/calendar/calendar.js
Normal file
1806
issue_relations/public/javascripts/calendar/calendar.js
Normal file
File diff suppressed because it is too large
Load Diff
128
issue_relations/public/javascripts/calendar/lang/calendar-de.js
Normal file
128
issue_relations/public/javascripts/calendar/lang/calendar-de.js
Normal file
@@ -0,0 +1,128 @@
|
||||
// ** I18N
|
||||
|
||||
// Calendar DE language
|
||||
// Author: Jack (tR), <jack@jtr.de>
|
||||
// Encoding: any
|
||||
// Distributed under the same terms as the calendar itself.
|
||||
|
||||
// For translators: please use UTF-8 if possible. We strongly believe that
|
||||
// Unicode is the answer to a real internationalized world. Also please
|
||||
// include your contact information in the header, as can be seen above.
|
||||
|
||||
// full day names
|
||||
Calendar._DN = new Array
|
||||
("Sonntag",
|
||||
"Montag",
|
||||
"Dienstag",
|
||||
"Mittwoch",
|
||||
"Donnerstag",
|
||||
"Freitag",
|
||||
"Samstag",
|
||||
"Sonntag");
|
||||
|
||||
// Please note that the following array of short day names (and the same goes
|
||||
// for short month names, _SMN) isn't absolutely necessary. We give it here
|
||||
// for exemplification on how one can customize the short day names, but if
|
||||
// they are simply the first N letters of the full name you can simply say:
|
||||
//
|
||||
// Calendar._SDN_len = N; // short day name length
|
||||
// Calendar._SMN_len = N; // short month name length
|
||||
//
|
||||
// If N = 3 then this is not needed either since we assume a value of 3 if not
|
||||
// present, to be compatible with translation files that were written before
|
||||
// this feature.
|
||||
|
||||
// First day of the week. "0" means display Sunday first, "1" means display
|
||||
// Monday first, etc.
|
||||
Calendar._FD = 1;
|
||||
|
||||
// short day names
|
||||
Calendar._SDN = new Array
|
||||
("So",
|
||||
"Mo",
|
||||
"Di",
|
||||
"Mi",
|
||||
"Do",
|
||||
"Fr",
|
||||
"Sa",
|
||||
"So");
|
||||
|
||||
// full month names
|
||||
Calendar._MN = new Array
|
||||
("Januar",
|
||||
"Februar",
|
||||
"M\u00e4rz",
|
||||
"April",
|
||||
"Mai",
|
||||
"Juni",
|
||||
"Juli",
|
||||
"August",
|
||||
"September",
|
||||
"Oktober",
|
||||
"November",
|
||||
"Dezember");
|
||||
|
||||
// short month names
|
||||
Calendar._SMN = new Array
|
||||
("Jan",
|
||||
"Feb",
|
||||
"M\u00e4r",
|
||||
"Apr",
|
||||
"May",
|
||||
"Jun",
|
||||
"Jul",
|
||||
"Aug",
|
||||
"Sep",
|
||||
"Okt",
|
||||
"Nov",
|
||||
"Dez");
|
||||
|
||||
// tooltips
|
||||
Calendar._TT = {};
|
||||
Calendar._TT["INFO"] = "\u00DCber dieses Kalendarmodul";
|
||||
|
||||
Calendar._TT["ABOUT"] =
|
||||
"DHTML Date/Time Selector\n" +
|
||||
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this ;-)
|
||||
"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
|
||||
"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
|
||||
"\n\n" +
|
||||
"Datum ausw\u00e4hlen:\n" +
|
||||
"- Benutzen Sie die \xab, \xbb Buttons um das Jahr zu w\u00e4hlen\n" +
|
||||
"- Benutzen Sie die " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " Buttons um den Monat zu w\u00e4hlen\n" +
|
||||
"- F\u00fcr eine Schnellauswahl halten Sie die Maustaste \u00fcber diesen Buttons fest.";
|
||||
Calendar._TT["ABOUT_TIME"] = "\n\n" +
|
||||
"Zeit ausw\u00e4hlen:\n" +
|
||||
"- Klicken Sie auf die Teile der Uhrzeit, um diese zu erh\u00F6hen\n" +
|
||||
"- oder klicken Sie mit festgehaltener Shift-Taste um diese zu verringern\n" +
|
||||
"- oder klicken und festhalten f\u00fcr Schnellauswahl.";
|
||||
|
||||
Calendar._TT["TOGGLE"] = "Ersten Tag der Woche w\u00e4hlen";
|
||||
Calendar._TT["PREV_YEAR"] = "Voriges Jahr (Festhalten f\u00fcr Schnellauswahl)";
|
||||
Calendar._TT["PREV_MONTH"] = "Voriger Monat (Festhalten f\u00fcr Schnellauswahl)";
|
||||
Calendar._TT["GO_TODAY"] = "Heute ausw\u00e4hlen";
|
||||
Calendar._TT["NEXT_MONTH"] = "N\u00e4chst. Monat (Festhalten f\u00fcr Schnellauswahl)";
|
||||
Calendar._TT["NEXT_YEAR"] = "N\u00e4chst. Jahr (Festhalten f\u00fcr Schnellauswahl)";
|
||||
Calendar._TT["SEL_DATE"] = "Datum ausw\u00e4hlen";
|
||||
Calendar._TT["DRAG_TO_MOVE"] = "Zum Bewegen festhalten";
|
||||
Calendar._TT["PART_TODAY"] = " (Heute)";
|
||||
|
||||
// the following is to inform that "%s" is to be the first day of week
|
||||
// %s will be replaced with the day name.
|
||||
Calendar._TT["DAY_FIRST"] = "Woche beginnt mit %s ";
|
||||
|
||||
// This may be locale-dependent. It specifies the week-end days, as an array
|
||||
// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
|
||||
// means Monday, etc.
|
||||
Calendar._TT["WEEKEND"] = "0,6";
|
||||
|
||||
Calendar._TT["CLOSE"] = "Schlie\u00dfen";
|
||||
Calendar._TT["TODAY"] = "Heute";
|
||||
Calendar._TT["TIME_PART"] = "(Shift-)Klick oder Festhalten und Ziehen um den Wert zu \u00e4ndern";
|
||||
|
||||
// date formats
|
||||
Calendar._TT["DEF_DATE_FORMAT"] = "%d.%m.%Y";
|
||||
Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
|
||||
|
||||
Calendar._TT["WK"] = "wk";
|
||||
Calendar._TT["TIME"] = "Zeit:";
|
||||
127
issue_relations/public/javascripts/calendar/lang/calendar-en.js
Normal file
127
issue_relations/public/javascripts/calendar/lang/calendar-en.js
Normal file
@@ -0,0 +1,127 @@
|
||||
// ** I18N
|
||||
|
||||
// Calendar EN language
|
||||
// Author: Mihai Bazon, <mihai_bazon@yahoo.com>
|
||||
// Encoding: any
|
||||
// Distributed under the same terms as the calendar itself.
|
||||
|
||||
// For translators: please use UTF-8 if possible. We strongly believe that
|
||||
// Unicode is the answer to a real internationalized world. Also please
|
||||
// include your contact information in the header, as can be seen above.
|
||||
|
||||
// full day names
|
||||
Calendar._DN = new Array
|
||||
("Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
"Sunday");
|
||||
|
||||
// Please note that the following array of short day names (and the same goes
|
||||
// for short month names, _SMN) isn't absolutely necessary. We give it here
|
||||
// for exemplification on how one can customize the short day names, but if
|
||||
// they are simply the first N letters of the full name you can simply say:
|
||||
//
|
||||
// Calendar._SDN_len = N; // short day name length
|
||||
// Calendar._SMN_len = N; // short month name length
|
||||
//
|
||||
// If N = 3 then this is not needed either since we assume a value of 3 if not
|
||||
// present, to be compatible with translation files that were written before
|
||||
// this feature.
|
||||
|
||||
// short day names
|
||||
Calendar._SDN = new Array
|
||||
("Sun",
|
||||
"Mon",
|
||||
"Tue",
|
||||
"Wed",
|
||||
"Thu",
|
||||
"Fri",
|
||||
"Sat",
|
||||
"Sun");
|
||||
|
||||
// First day of the week. "0" means display Sunday first, "1" means display
|
||||
// Monday first, etc.
|
||||
Calendar._FD = 0;
|
||||
|
||||
// full month names
|
||||
Calendar._MN = new Array
|
||||
("January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December");
|
||||
|
||||
// short month names
|
||||
Calendar._SMN = new Array
|
||||
("Jan",
|
||||
"Feb",
|
||||
"Mar",
|
||||
"Apr",
|
||||
"May",
|
||||
"Jun",
|
||||
"Jul",
|
||||
"Aug",
|
||||
"Sep",
|
||||
"Oct",
|
||||
"Nov",
|
||||
"Dec");
|
||||
|
||||
// tooltips
|
||||
Calendar._TT = {};
|
||||
Calendar._TT["INFO"] = "About the calendar";
|
||||
|
||||
Calendar._TT["ABOUT"] =
|
||||
"DHTML Date/Time Selector\n" +
|
||||
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
|
||||
"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
|
||||
"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
|
||||
"\n\n" +
|
||||
"Date selection:\n" +
|
||||
"- Use the \xab, \xbb buttons to select year\n" +
|
||||
"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
|
||||
"- Hold mouse button on any of the above buttons for faster selection.";
|
||||
Calendar._TT["ABOUT_TIME"] = "\n\n" +
|
||||
"Time selection:\n" +
|
||||
"- Click on any of the time parts to increase it\n" +
|
||||
"- or Shift-click to decrease it\n" +
|
||||
"- or click and drag for faster selection.";
|
||||
|
||||
Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)";
|
||||
Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)";
|
||||
Calendar._TT["GO_TODAY"] = "Go Today";
|
||||
Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)";
|
||||
Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)";
|
||||
Calendar._TT["SEL_DATE"] = "Select date";
|
||||
Calendar._TT["DRAG_TO_MOVE"] = "Drag to move";
|
||||
Calendar._TT["PART_TODAY"] = " (today)";
|
||||
|
||||
// the following is to inform that "%s" is to be the first day of week
|
||||
// %s will be replaced with the day name.
|
||||
Calendar._TT["DAY_FIRST"] = "Display %s first";
|
||||
|
||||
// This may be locale-dependent. It specifies the week-end days, as an array
|
||||
// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
|
||||
// means Monday, etc.
|
||||
Calendar._TT["WEEKEND"] = "0,6";
|
||||
|
||||
Calendar._TT["CLOSE"] = "Close";
|
||||
Calendar._TT["TODAY"] = "Today";
|
||||
Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";
|
||||
|
||||
// date formats
|
||||
Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
|
||||
Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
|
||||
|
||||
Calendar._TT["WK"] = "wk";
|
||||
Calendar._TT["TIME"] = "Time:";
|
||||
129
issue_relations/public/javascripts/calendar/lang/calendar-es.js
Normal file
129
issue_relations/public/javascripts/calendar/lang/calendar-es.js
Normal file
@@ -0,0 +1,129 @@
|
||||
// ** I18N
|
||||
|
||||
// Calendar ES (spanish) language
|
||||
// Author: Mihai Bazon, <mihai_bazon@yahoo.com>
|
||||
// Updater: Servilio Afre Puentes <servilios@yahoo.com>
|
||||
// Updated: 2004-06-03
|
||||
// Encoding: utf-8
|
||||
// Distributed under the same terms as the calendar itself.
|
||||
|
||||
// For translators: please use UTF-8 if possible. We strongly believe that
|
||||
// Unicode is the answer to a real internationalized world. Also please
|
||||
// include your contact information in the header, as can be seen above.
|
||||
|
||||
// full day names
|
||||
Calendar._DN = new Array
|
||||
("Domingo",
|
||||
"Lunes",
|
||||
"Martes",
|
||||
"Miércoles",
|
||||
"Jueves",
|
||||
"Viernes",
|
||||
"Sábado",
|
||||
"Domingo");
|
||||
|
||||
// Please note that the following array of short day names (and the same goes
|
||||
// for short month names, _SMN) isn't absolutely necessary. We give it here
|
||||
// for exemplification on how one can customize the short day names, but if
|
||||
// they are simply the first N letters of the full name you can simply say:
|
||||
//
|
||||
// Calendar._SDN_len = N; // short day name length
|
||||
// Calendar._SMN_len = N; // short month name length
|
||||
//
|
||||
// If N = 3 then this is not needed either since we assume a value of 3 if not
|
||||
// present, to be compatible with translation files that were written before
|
||||
// this feature.
|
||||
|
||||
// short day names
|
||||
Calendar._SDN = new Array
|
||||
("Dom",
|
||||
"Lun",
|
||||
"Mar",
|
||||
"Mié",
|
||||
"Jue",
|
||||
"Vie",
|
||||
"Sáb",
|
||||
"Dom");
|
||||
|
||||
// First day of the week. "0" means display Sunday first, "1" means display
|
||||
// Monday first, etc.
|
||||
Calendar._FD = 1;
|
||||
|
||||
// full month names
|
||||
Calendar._MN = new Array
|
||||
("Enero",
|
||||
"Febrero",
|
||||
"Marzo",
|
||||
"Abril",
|
||||
"Mayo",
|
||||
"Junio",
|
||||
"Julio",
|
||||
"Agosto",
|
||||
"Septiembre",
|
||||
"Octubre",
|
||||
"Noviembre",
|
||||
"Diciembre");
|
||||
|
||||
// short month names
|
||||
Calendar._SMN = new Array
|
||||
("Ene",
|
||||
"Feb",
|
||||
"Mar",
|
||||
"Abr",
|
||||
"May",
|
||||
"Jun",
|
||||
"Jul",
|
||||
"Ago",
|
||||
"Sep",
|
||||
"Oct",
|
||||
"Nov",
|
||||
"Dic");
|
||||
|
||||
// tooltips
|
||||
Calendar._TT = {};
|
||||
Calendar._TT["INFO"] = "Acerca del calendario";
|
||||
|
||||
Calendar._TT["ABOUT"] =
|
||||
"Selector DHTML de Fecha/Hora\n" +
|
||||
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
|
||||
"Para conseguir la última versión visite: http://www.dynarch.com/projects/calendar/\n" +
|
||||
"Distribuido bajo licencia GNU LGPL. Visite http://gnu.org/licenses/lgpl.html para más detalles." +
|
||||
"\n\n" +
|
||||
"Selección de fecha:\n" +
|
||||
"- Use los botones \xab, \xbb para seleccionar el año\n" +
|
||||
"- Use los botones " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " para seleccionar el mes\n" +
|
||||
"- Mantenga pulsado el ratón en cualquiera de estos botones para una selección rápida.";
|
||||
Calendar._TT["ABOUT_TIME"] = "\n\n" +
|
||||
"Selección de hora:\n" +
|
||||
"- Pulse en cualquiera de las partes de la hora para incrementarla\n" +
|
||||
"- o pulse las mayúsculas mientras hace clic para decrementarla\n" +
|
||||
"- o haga clic y arrastre el ratón para una selección más rápida.";
|
||||
|
||||
Calendar._TT["PREV_YEAR"] = "Año anterior (mantener para menú)";
|
||||
Calendar._TT["PREV_MONTH"] = "Mes anterior (mantener para menú)";
|
||||
Calendar._TT["GO_TODAY"] = "Ir a hoy";
|
||||
Calendar._TT["NEXT_MONTH"] = "Mes siguiente (mantener para menú)";
|
||||
Calendar._TT["NEXT_YEAR"] = "Año siguiente (mantener para menú)";
|
||||
Calendar._TT["SEL_DATE"] = "Seleccionar fecha";
|
||||
Calendar._TT["DRAG_TO_MOVE"] = "Arrastrar para mover";
|
||||
Calendar._TT["PART_TODAY"] = " (hoy)";
|
||||
|
||||
// the following is to inform that "%s" is to be the first day of week
|
||||
// %s will be replaced with the day name.
|
||||
Calendar._TT["DAY_FIRST"] = "Hacer %s primer día de la semana";
|
||||
|
||||
// This may be locale-dependent. It specifies the week-end days, as an array
|
||||
// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
|
||||
// means Monday, etc.
|
||||
Calendar._TT["WEEKEND"] = "0,6";
|
||||
|
||||
Calendar._TT["CLOSE"] = "Cerrar";
|
||||
Calendar._TT["TODAY"] = "Hoy";
|
||||
Calendar._TT["TIME_PART"] = "(Mayúscula-)Clic o arrastre para cambiar valor";
|
||||
|
||||
// date formats
|
||||
Calendar._TT["DEF_DATE_FORMAT"] = "%d/%m/%Y";
|
||||
Calendar._TT["TT_DATE_FORMAT"] = "%A, %e de %B de %Y";
|
||||
|
||||
Calendar._TT["WK"] = "sem";
|
||||
Calendar._TT["TIME"] = "Hora:";
|
||||
129
issue_relations/public/javascripts/calendar/lang/calendar-fr.js
Normal file
129
issue_relations/public/javascripts/calendar/lang/calendar-fr.js
Normal file
@@ -0,0 +1,129 @@
|
||||
// ** I18N
|
||||
|
||||
// Calendar EN language
|
||||
// Author: Mihai Bazon, <mihai_bazon@yahoo.com>
|
||||
// Encoding: any
|
||||
// Distributed under the same terms as the calendar itself.
|
||||
|
||||
// For translators: please use UTF-8 if possible. We strongly believe that
|
||||
// Unicode is the answer to a real internationalized world. Also please
|
||||
// include your contact information in the header, as can be seen above.
|
||||
|
||||
// Translator: David Duret, <pilgrim@mala-template.net> from previous french version
|
||||
|
||||
// full day names
|
||||
Calendar._DN = new Array
|
||||
("Dimanche",
|
||||
"Lundi",
|
||||
"Mardi",
|
||||
"Mercredi",
|
||||
"Jeudi",
|
||||
"Vendredi",
|
||||
"Samedi",
|
||||
"Dimanche");
|
||||
|
||||
// Please note that the following array of short day names (and the same goes
|
||||
// for short month names, _SMN) isn't absolutely necessary. We give it here
|
||||
// for exemplification on how one can customize the short day names, but if
|
||||
// they are simply the first N letters of the full name you can simply say:
|
||||
//
|
||||
// Calendar._SDN_len = N; // short day name length
|
||||
// Calendar._SMN_len = N; // short month name length
|
||||
//
|
||||
// If N = 3 then this is not needed either since we assume a value of 3 if not
|
||||
// present, to be compatible with translation files that were written before
|
||||
// this feature.
|
||||
|
||||
// short day names
|
||||
Calendar._SDN = new Array
|
||||
("Dim",
|
||||
"Lun",
|
||||
"Mar",
|
||||
"Mar",
|
||||
"Jeu",
|
||||
"Ven",
|
||||
"Sam",
|
||||
"Dim");
|
||||
|
||||
// First day of the week. "0" means display Sunday first, "1" means display
|
||||
// Monday first, etc.
|
||||
Calendar._FD = 1;
|
||||
|
||||
// full month names
|
||||
Calendar._MN = new Array
|
||||
("Janvier",
|
||||
"Février",
|
||||
"Mars",
|
||||
"Avril",
|
||||
"Mai",
|
||||
"Juin",
|
||||
"Juillet",
|
||||
"Août",
|
||||
"Septembre",
|
||||
"Octobre",
|
||||
"Novembre",
|
||||
"Décembre");
|
||||
|
||||
// short month names
|
||||
Calendar._SMN = new Array
|
||||
("Jan",
|
||||
"Fev",
|
||||
"Mar",
|
||||
"Avr",
|
||||
"Mai",
|
||||
"Juin",
|
||||
"Juil",
|
||||
"Aout",
|
||||
"Sep",
|
||||
"Oct",
|
||||
"Nov",
|
||||
"Dec");
|
||||
|
||||
// tooltips
|
||||
Calendar._TT = {};
|
||||
Calendar._TT["INFO"] = "A propos du calendrier";
|
||||
|
||||
Calendar._TT["ABOUT"] =
|
||||
"DHTML Date/Heure Selecteur\n" +
|
||||
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
|
||||
"Pour la derniere version visitez : http://www.dynarch.com/projects/calendar/\n" +
|
||||
"Distribué par GNU LGPL. Voir http://gnu.org/licenses/lgpl.html pour les details." +
|
||||
"\n\n" +
|
||||
"Selection de la date :\n" +
|
||||
"- Utiliser les bouttons \xab, \xbb pour selectionner l\'annee\n" +
|
||||
"- Utiliser les bouttons " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " pour selectionner les mois\n" +
|
||||
"- Garder la souris sur n'importe quels boutons pour une selection plus rapide";
|
||||
Calendar._TT["ABOUT_TIME"] = "\n\n" +
|
||||
"Selection de l\'heure :\n" +
|
||||
"- Cliquer sur heures ou minutes pour incrementer\n" +
|
||||
"- ou Maj-clic pour decrementer\n" +
|
||||
"- ou clic et glisser-deplacer pour une selection plus rapide";
|
||||
|
||||
Calendar._TT["PREV_YEAR"] = "Année préc. (maintenir pour menu)";
|
||||
Calendar._TT["PREV_MONTH"] = "Mois préc. (maintenir pour menu)";
|
||||
Calendar._TT["GO_TODAY"] = "Atteindre la date du jour";
|
||||
Calendar._TT["NEXT_MONTH"] = "Mois suiv. (maintenir pour menu)";
|
||||
Calendar._TT["NEXT_YEAR"] = "Année suiv. (maintenir pour menu)";
|
||||
Calendar._TT["SEL_DATE"] = "Sélectionner une date";
|
||||
Calendar._TT["DRAG_TO_MOVE"] = "Déplacer";
|
||||
Calendar._TT["PART_TODAY"] = " (Aujourd'hui)";
|
||||
|
||||
// the following is to inform that "%s" is to be the first day of week
|
||||
// %s will be replaced with the day name.
|
||||
Calendar._TT["DAY_FIRST"] = "Afficher %s en premier";
|
||||
|
||||
// This may be locale-dependent. It specifies the week-end days, as an array
|
||||
// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
|
||||
// means Monday, etc.
|
||||
Calendar._TT["WEEKEND"] = "0,6";
|
||||
|
||||
Calendar._TT["CLOSE"] = "Fermer";
|
||||
Calendar._TT["TODAY"] = "Aujourd'hui";
|
||||
Calendar._TT["TIME_PART"] = "(Maj-)Clic ou glisser pour modifier la valeur";
|
||||
|
||||
// date formats
|
||||
Calendar._TT["DEF_DATE_FORMAT"] = "%d/%m/%Y";
|
||||
Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
|
||||
|
||||
Calendar._TT["WK"] = "Sem.";
|
||||
Calendar._TT["TIME"] = "Heure :";
|
||||
750
issue_relations/public/javascripts/controls.js
vendored
Normal file
750
issue_relations/public/javascripts/controls.js
vendored
Normal file
@@ -0,0 +1,750 @@
|
||||
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||
// (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
|
||||
// (c) 2005 Jon Tirsen (http://www.tirsen.com)
|
||||
// Contributors:
|
||||
// Richard Livsey
|
||||
// Rahul Bhargava
|
||||
// Rob Wills
|
||||
//
|
||||
// See scriptaculous.js for full license.
|
||||
|
||||
// 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.getToken(), 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: [',', '\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 = {
|
||||
baseInitialize: function(element, update, options) {
|
||||
this.element = $(element);
|
||||
this.update = $(update);
|
||||
this.hasFocus = false;
|
||||
this.changed = false;
|
||||
this.active = false;
|
||||
this.index = 0;
|
||||
this.entryCount = 0;
|
||||
|
||||
if (this.setOptions)
|
||||
this.setOptions(options);
|
||||
else
|
||||
this.options = options || {};
|
||||
|
||||
this.options.paramName = this.options.paramName || this.element.name;
|
||||
this.options.tokens = this.options.tokens || [];
|
||||
this.options.frequency = this.options.frequency || 0.4;
|
||||
this.options.minChars = this.options.minChars || 1;
|
||||
this.options.onShow = this.options.onShow ||
|
||||
function(element, update){
|
||||
if(!update.style.position || update.style.position=='absolute') {
|
||||
update.style.position = 'absolute';
|
||||
Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight});
|
||||
}
|
||||
Effect.Appear(update,{duration:0.15});
|
||||
};
|
||||
this.options.onHide = this.options.onHide ||
|
||||
function(element, update){ new Effect.Fade(update,{duration:0.15}) };
|
||||
|
||||
if (typeof(this.options.tokens) == 'string')
|
||||
this.options.tokens = new Array(this.options.tokens);
|
||||
|
||||
this.observer = null;
|
||||
|
||||
this.element.setAttribute('autocomplete','off');
|
||||
|
||||
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(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
|
||||
if(!this.iefix &&
|
||||
(navigator.appVersion.indexOf('MSIE')>0) &&
|
||||
(navigator.userAgent.indexOf('Opera')<0) &&
|
||||
(Element.getStyle(this.update, 'position')=='absolute')) {
|
||||
new Insertion.After(this.update,
|
||||
'<iframe id="' + this.update.id + '_iefix" '+
|
||||
'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
|
||||
'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
|
||||
this.iefix = $(this.update.id+'_iefix');
|
||||
}
|
||||
if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
|
||||
},
|
||||
|
||||
fixIEOverlapping: function() {
|
||||
Position.clone(this.update, this.iefix);
|
||||
this.iefix.style.zIndex = 1;
|
||||
this.update.style.zIndex = 2;
|
||||
Element.show(this.iefix);
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.stopIndicator();
|
||||
if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
|
||||
if(this.iefix) Element.hide(this.iefix);
|
||||
},
|
||||
|
||||
startIndicator: function() {
|
||||
if(this.options.indicator) Element.show(this.options.indicator);
|
||||
},
|
||||
|
||||
stopIndicator: function() {
|
||||
if(this.options.indicator) Element.hide(this.options.indicator);
|
||||
},
|
||||
|
||||
onKeyPress: function(event) {
|
||||
if(this.active)
|
||||
switch(event.keyCode) {
|
||||
case Event.KEY_TAB:
|
||||
case Event.KEY_RETURN:
|
||||
this.selectEntry();
|
||||
Event.stop(event);
|
||||
case Event.KEY_ESC:
|
||||
this.hide();
|
||||
this.active = false;
|
||||
Event.stop(event);
|
||||
return;
|
||||
case Event.KEY_LEFT:
|
||||
case Event.KEY_RIGHT:
|
||||
return;
|
||||
case Event.KEY_UP:
|
||||
this.markPrevious();
|
||||
this.render();
|
||||
if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
|
||||
return;
|
||||
case Event.KEY_DOWN:
|
||||
this.markNext();
|
||||
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.hasFocus = 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.selectEntry();
|
||||
this.hide();
|
||||
},
|
||||
|
||||
onBlur: function(event) {
|
||||
// needed to make click events working
|
||||
setTimeout(this.hide.bind(this), 250);
|
||||
this.hasFocus = false;
|
||||
this.active = false;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
if(this.entryCount > 0) {
|
||||
for (var i = 0; i < this.entryCount; i++)
|
||||
this.index==i ?
|
||||
Element.addClassName(this.getEntry(i),"selected") :
|
||||
Element.removeClassName(this.getEntry(i),"selected");
|
||||
|
||||
if(this.hasFocus) {
|
||||
this.show();
|
||||
this.active = true;
|
||||
}
|
||||
} else {
|
||||
this.active = false;
|
||||
this.hide();
|
||||
}
|
||||
},
|
||||
|
||||
markPrevious: function() {
|
||||
if(this.index > 0) this.index--
|
||||
else this.index = this.entryCount-1;
|
||||
},
|
||||
|
||||
markNext: function() {
|
||||
if(this.index < this.entryCount-1) this.index++
|
||||
else this.index = 0;
|
||||
},
|
||||
|
||||
getEntry: function(index) {
|
||||
return this.update.firstChild.childNodes[index];
|
||||
},
|
||||
|
||||
getCurrentEntry: function() {
|
||||
return this.getEntry(this.index);
|
||||
},
|
||||
|
||||
selectEntry: function() {
|
||||
this.active = false;
|
||||
this.updateElement(this.getCurrentEntry());
|
||||
},
|
||||
|
||||
updateElement: function(selectedElement) {
|
||||
if (this.options.updateElement) {
|
||||
this.options.updateElement(selectedElement);
|
||||
return;
|
||||
}
|
||||
|
||||
var value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
|
||||
var lastTokenPos = this.findLastToken();
|
||||
if (lastTokenPos != -1) {
|
||||
var newValue = this.element.value.substr(0, lastTokenPos + 1);
|
||||
var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/);
|
||||
if (whitespace)
|
||||
newValue += whitespace[0];
|
||||
this.element.value = newValue + value;
|
||||
} else {
|
||||
this.element.value = value;
|
||||
}
|
||||
this.element.focus();
|
||||
|
||||
if (this.options.afterUpdateElement)
|
||||
this.options.afterUpdateElement(this.element, selectedElement);
|
||||
},
|
||||
|
||||
updateChoices: function(choices) {
|
||||
if(!this.changed && this.hasFocus) {
|
||||
this.update.innerHTML = choices;
|
||||
Element.cleanWhitespace(this.update);
|
||||
Element.cleanWhitespace(this.update.firstChild);
|
||||
|
||||
if(this.update.firstChild && this.update.firstChild.childNodes) {
|
||||
this.entryCount =
|
||||
this.update.firstChild.childNodes.length;
|
||||
for (var i = 0; i < this.entryCount; i++) {
|
||||
var entry = this.getEntry(i);
|
||||
entry.autocompleteIndex = i;
|
||||
this.addObservers(entry);
|
||||
}
|
||||
} else {
|
||||
this.entryCount = 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.getToken().length>=this.options.minChars) {
|
||||
this.startIndicator();
|
||||
this.getUpdatedChoices();
|
||||
} else {
|
||||
this.active = false;
|
||||
this.hide();
|
||||
}
|
||||
},
|
||||
|
||||
getToken: function() {
|
||||
var tokenPos = this.findLastToken();
|
||||
if (tokenPos != -1)
|
||||
var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,'');
|
||||
else
|
||||
var ret = this.element.value;
|
||||
|
||||
return /\n/.test(ret) ? '' : ret;
|
||||
},
|
||||
|
||||
findLastToken: function() {
|
||||
var lastTokenPos = -1;
|
||||
|
||||
for (var i=0; i<this.options.tokens.length; i++) {
|
||||
var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]);
|
||||
if (thisTokenPos > lastTokenPos)
|
||||
lastTokenPos = thisTokenPos;
|
||||
}
|
||||
return lastTokenPos;
|
||||
}
|
||||
}
|
||||
|
||||
Ajax.Autocompleter = Class.create();
|
||||
Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
|
||||
initialize: function(element, update, url, options) {
|
||||
this.baseInitialize(element, update, options);
|
||||
this.options.asynchronous = true;
|
||||
this.options.onComplete = this.onComplete.bind(this);
|
||||
this.options.defaultParams = this.options.parameters || null;
|
||||
this.url = url;
|
||||
},
|
||||
|
||||
getUpdatedChoices: function() {
|
||||
entry = encodeURIComponent(this.options.paramName) + '=' +
|
||||
encodeURIComponent(this.getToken());
|
||||
|
||||
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
|
||||
//
|
||||
// - partialSearch - 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 fullSearch to true (default: off).
|
||||
//
|
||||
// - fullSsearch - Search anywhere in autocomplete array strings.
|
||||
//
|
||||
// - partialChars - How many characters to enter before triggering
|
||||
// a partial match (unlike minChars, which defines
|
||||
// how many characters are required to do any match
|
||||
// at all). Defaults to 2.
|
||||
//
|
||||
// - ignoreCase - 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.baseInitialize(element, update, options);
|
||||
this.options.array = array;
|
||||
},
|
||||
|
||||
getUpdatedChoices: function() {
|
||||
this.updateChoices(this.options.selector(this));
|
||||
},
|
||||
|
||||
setOptions: function(options) {
|
||||
this.options = Object.extend({
|
||||
choices: 10,
|
||||
partialSearch: true,
|
||||
partialChars: 2,
|
||||
ignoreCase: true,
|
||||
fullSearch: false,
|
||||
selector: function(instance) {
|
||||
var ret = []; // Beginning matches
|
||||
var partial = []; // Inside matches
|
||||
var entry = instance.getToken();
|
||||
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 foundPos = instance.options.ignoreCase ?
|
||||
elem.toLowerCase().indexOf(entry.toLowerCase()) :
|
||||
elem.indexOf(entry);
|
||||
|
||||
while (foundPos != -1) {
|
||||
if (foundPos == 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.partialChars &&
|
||||
instance.options.partialSearch && foundPos != -1) {
|
||||
if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
|
||||
partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
|
||||
elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(
|
||||
foundPos + entry.length) + "</li>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foundPos = instance.options.ignoreCase ?
|
||||
elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
|
||||
elem.indexOf(entry, foundPos + 1);
|
||||
|
||||
}
|
||||
}
|
||||
if (partial.length)
|
||||
ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
|
||||
return "<ul>" + ret.join('') + "</ul>";
|
||||
}
|
||||
}, options || {});
|
||||
}
|
||||
});
|
||||
|
||||
// AJAX in-place editor
|
||||
//
|
||||
// see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
|
||||
|
||||
// Use this if you notice weird scrolling problems on some browsers,
|
||||
// the DOM might be a bit confused when this gets called so do this
|
||||
// waits 1 ms (with setTimeout) until it does the activation
|
||||
Field.scrollFreeActivate = function(field) {
|
||||
setTimeout(function() {
|
||||
Field.activate(field);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
Ajax.InPlaceEditor = Class.create();
|
||||
Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
|
||||
Ajax.InPlaceEditor.prototype = {
|
||||
initialize: function(element, url, options) {
|
||||
this.url = url;
|
||||
this.element = $(element);
|
||||
|
||||
this.options = Object.extend({
|
||||
okText: "ok",
|
||||
cancelText: "cancel",
|
||||
savingText: "Saving...",
|
||||
clickToEditText: "Click to edit",
|
||||
okText: "ok",
|
||||
rows: 1,
|
||||
onComplete: function(transport, element) {
|
||||
new Effect.Highlight(element, {startcolor: this.options.highlightcolor});
|
||||
},
|
||||
onFailure: function(transport) {
|
||||
alert("Error communicating with the server: " + transport.responseText.stripTags());
|
||||
},
|
||||
callback: function(form) {
|
||||
return Form.serialize(form);
|
||||
},
|
||||
handleLineBreaks: true,
|
||||
loadingText: 'Loading...',
|
||||
savingClassName: 'inplaceeditor-saving',
|
||||
loadingClassName: 'inplaceeditor-loading',
|
||||
formClassName: 'inplaceeditor-form',
|
||||
highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
|
||||
highlightendcolor: "#FFFFFF",
|
||||
externalControl: null,
|
||||
ajaxOptions: {}
|
||||
}, options || {});
|
||||
|
||||
if(!this.options.formId && this.element.id) {
|
||||
this.options.formId = this.element.id + "-inplaceeditor";
|
||||
if ($(this.options.formId)) {
|
||||
// there's already a form with that name, don't specify an id
|
||||
this.options.formId = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.options.externalControl) {
|
||||
this.options.externalControl = $(this.options.externalControl);
|
||||
}
|
||||
|
||||
this.originalBackground = Element.getStyle(this.element, 'background-color');
|
||||
if (!this.originalBackground) {
|
||||
this.originalBackground = "transparent";
|
||||
}
|
||||
|
||||
this.element.title = this.options.clickToEditText;
|
||||
|
||||
this.onclickListener = this.enterEditMode.bindAsEventListener(this);
|
||||
this.mouseoverListener = this.enterHover.bindAsEventListener(this);
|
||||
this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
|
||||
Event.observe(this.element, 'click', this.onclickListener);
|
||||
Event.observe(this.element, 'mouseover', this.mouseoverListener);
|
||||
Event.observe(this.element, 'mouseout', this.mouseoutListener);
|
||||
if (this.options.externalControl) {
|
||||
Event.observe(this.options.externalControl, 'click', this.onclickListener);
|
||||
Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
|
||||
Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
|
||||
}
|
||||
},
|
||||
enterEditMode: function(evt) {
|
||||
if (this.saving) return;
|
||||
if (this.editing) return;
|
||||
this.editing = true;
|
||||
this.onEnterEditMode();
|
||||
if (this.options.externalControl) {
|
||||
Element.hide(this.options.externalControl);
|
||||
}
|
||||
Element.hide(this.element);
|
||||
this.createForm();
|
||||
this.element.parentNode.insertBefore(this.form, this.element);
|
||||
Field.scrollFreeActivate(this.editField);
|
||||
// stop the event to avoid a page refresh in Safari
|
||||
if (evt) {
|
||||
Event.stop(evt);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
createForm: function() {
|
||||
this.form = document.createElement("form");
|
||||
this.form.id = this.options.formId;
|
||||
Element.addClassName(this.form, this.options.formClassName)
|
||||
this.form.onsubmit = this.onSubmit.bind(this);
|
||||
|
||||
this.createEditField();
|
||||
|
||||
if (this.options.textarea) {
|
||||
var br = document.createElement("br");
|
||||
this.form.appendChild(br);
|
||||
}
|
||||
|
||||
okButton = document.createElement("input");
|
||||
okButton.type = "submit";
|
||||
okButton.value = this.options.okText;
|
||||
this.form.appendChild(okButton);
|
||||
|
||||
cancelLink = document.createElement("a");
|
||||
cancelLink.href = "#";
|
||||
cancelLink.appendChild(document.createTextNode(this.options.cancelText));
|
||||
cancelLink.onclick = this.onclickCancel.bind(this);
|
||||
this.form.appendChild(cancelLink);
|
||||
},
|
||||
hasHTMLLineBreaks: function(string) {
|
||||
if (!this.options.handleLineBreaks) return false;
|
||||
return string.match(/<br/i) || string.match(/<p>/i);
|
||||
},
|
||||
convertHTMLLineBreaks: function(string) {
|
||||
return string.replace(/<br>/gi, "\n").replace(/<br\/>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<p>/gi, "");
|
||||
},
|
||||
createEditField: function() {
|
||||
var text;
|
||||
if(this.options.loadTextURL) {
|
||||
text = this.options.loadingText;
|
||||
} else {
|
||||
text = this.getText();
|
||||
}
|
||||
|
||||
if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
|
||||
this.options.textarea = false;
|
||||
var textField = document.createElement("input");
|
||||
textField.type = "text";
|
||||
textField.name = "value";
|
||||
textField.value = text;
|
||||
textField.style.backgroundColor = this.options.highlightcolor;
|
||||
var size = this.options.size || this.options.cols || 0;
|
||||
if (size != 0) textField.size = size;
|
||||
this.editField = textField;
|
||||
} else {
|
||||
this.options.textarea = true;
|
||||
var textArea = document.createElement("textarea");
|
||||
textArea.name = "value";
|
||||
textArea.value = this.convertHTMLLineBreaks(text);
|
||||
textArea.rows = this.options.rows;
|
||||
textArea.cols = this.options.cols || 40;
|
||||
this.editField = textArea;
|
||||
}
|
||||
|
||||
if(this.options.loadTextURL) {
|
||||
this.loadExternalText();
|
||||
}
|
||||
this.form.appendChild(this.editField);
|
||||
},
|
||||
getText: function() {
|
||||
return this.element.innerHTML;
|
||||
},
|
||||
loadExternalText: function() {
|
||||
Element.addClassName(this.form, this.options.loadingClassName);
|
||||
this.editField.disabled = true;
|
||||
new Ajax.Request(
|
||||
this.options.loadTextURL,
|
||||
Object.extend({
|
||||
asynchronous: true,
|
||||
onComplete: this.onLoadedExternalText.bind(this)
|
||||
}, this.options.ajaxOptions)
|
||||
);
|
||||
},
|
||||
onLoadedExternalText: function(transport) {
|
||||
Element.removeClassName(this.form, this.options.loadingClassName);
|
||||
this.editField.disabled = false;
|
||||
this.editField.value = transport.responseText.stripTags();
|
||||
},
|
||||
onclickCancel: function() {
|
||||
this.onComplete();
|
||||
this.leaveEditMode();
|
||||
return false;
|
||||
},
|
||||
onFailure: function(transport) {
|
||||
this.options.onFailure(transport);
|
||||
if (this.oldInnerHTML) {
|
||||
this.element.innerHTML = this.oldInnerHTML;
|
||||
this.oldInnerHTML = null;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
onSubmit: function() {
|
||||
// onLoading resets these so we need to save them away for the Ajax call
|
||||
var form = this.form;
|
||||
var value = this.editField.value;
|
||||
|
||||
// do this first, sometimes the ajax call returns before we get a chance to switch on Saving...
|
||||
// which means this will actually switch on Saving... *after* we've left edit mode causing Saving...
|
||||
// to be displayed indefinitely
|
||||
this.onLoading();
|
||||
|
||||
new Ajax.Updater(
|
||||
{
|
||||
success: this.element,
|
||||
// don't update on failure (this could be an option)
|
||||
failure: null
|
||||
},
|
||||
this.url,
|
||||
Object.extend({
|
||||
parameters: this.options.callback(form, value),
|
||||
onComplete: this.onComplete.bind(this),
|
||||
onFailure: this.onFailure.bind(this)
|
||||
}, this.options.ajaxOptions)
|
||||
);
|
||||
// stop the event to avoid a page refresh in Safari
|
||||
if (arguments.length > 1) {
|
||||
Event.stop(arguments[0]);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
onLoading: function() {
|
||||
this.saving = true;
|
||||
this.removeForm();
|
||||
this.leaveHover();
|
||||
this.showSaving();
|
||||
},
|
||||
showSaving: function() {
|
||||
this.oldInnerHTML = this.element.innerHTML;
|
||||
this.element.innerHTML = this.options.savingText;
|
||||
Element.addClassName(this.element, this.options.savingClassName);
|
||||
this.element.style.backgroundColor = this.originalBackground;
|
||||
Element.show(this.element);
|
||||
},
|
||||
removeForm: function() {
|
||||
if(this.form) {
|
||||
if (this.form.parentNode) Element.remove(this.form);
|
||||
this.form = null;
|
||||
}
|
||||
},
|
||||
enterHover: function() {
|
||||
if (this.saving) return;
|
||||
this.element.style.backgroundColor = this.options.highlightcolor;
|
||||
if (this.effect) {
|
||||
this.effect.cancel();
|
||||
}
|
||||
Element.addClassName(this.element, this.options.hoverClassName)
|
||||
},
|
||||
leaveHover: function() {
|
||||
if (this.options.backgroundColor) {
|
||||
this.element.style.backgroundColor = this.oldBackground;
|
||||
}
|
||||
Element.removeClassName(this.element, this.options.hoverClassName)
|
||||
if (this.saving) return;
|
||||
this.effect = new Effect.Highlight(this.element, {
|
||||
startcolor: this.options.highlightcolor,
|
||||
endcolor: this.options.highlightendcolor,
|
||||
restorecolor: this.originalBackground
|
||||
});
|
||||
},
|
||||
leaveEditMode: function() {
|
||||
Element.removeClassName(this.element, this.options.savingClassName);
|
||||
this.removeForm();
|
||||
this.leaveHover();
|
||||
this.element.style.backgroundColor = this.originalBackground;
|
||||
Element.show(this.element);
|
||||
if (this.options.externalControl) {
|
||||
Element.show(this.options.externalControl);
|
||||
}
|
||||
this.editing = false;
|
||||
this.saving = false;
|
||||
this.oldInnerHTML = null;
|
||||
this.onLeaveEditMode();
|
||||
},
|
||||
onComplete: function(transport) {
|
||||
this.leaveEditMode();
|
||||
this.options.onComplete.bind(this)(transport, this.element);
|
||||
},
|
||||
onEnterEditMode: function() {},
|
||||
onLeaveEditMode: function() {},
|
||||
dispose: function() {
|
||||
if (this.oldInnerHTML) {
|
||||
this.element.innerHTML = this.oldInnerHTML;
|
||||
}
|
||||
this.leaveEditMode();
|
||||
Event.stopObserving(this.element, 'click', this.onclickListener);
|
||||
Event.stopObserving(this.element, 'mouseover', this.mouseoverListener);
|
||||
Event.stopObserving(this.element, 'mouseout', this.mouseoutListener);
|
||||
if (this.options.externalControl) {
|
||||
Event.stopObserving(this.options.externalControl, 'click', this.onclickListener);
|
||||
Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener);
|
||||
Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Delayed observer, like Form.Element.Observer,
|
||||
// but waits for delay after last key input
|
||||
// Ideal for live-search fields
|
||||
|
||||
Form.Element.DelayedObserver = Class.create();
|
||||
Form.Element.DelayedObserver.prototype = {
|
||||
initialize: function(element, delay, callback) {
|
||||
this.delay = delay || 0.5;
|
||||
this.element = $(element);
|
||||
this.callback = callback;
|
||||
this.timer = null;
|
||||
this.lastValue = $F(this.element);
|
||||
Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
|
||||
},
|
||||
delayedListener: function(event) {
|
||||
if(this.lastValue == $F(this.element)) return;
|
||||
if(this.timer) clearTimeout(this.timer);
|
||||
this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
|
||||
this.lastValue = $F(this.element);
|
||||
},
|
||||
onTimerEvent: function() {
|
||||
this.timer = null;
|
||||
this.callback(this.element, $F(this.element));
|
||||
}
|
||||
};
|
||||
584
issue_relations/public/javascripts/dragdrop.js
vendored
Normal file
584
issue_relations/public/javascripts/dragdrop.js
vendored
Normal file
@@ -0,0 +1,584 @@
|
||||
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||
//
|
||||
// See scriptaculous.js for full license.
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
var Droppables = {
|
||||
drops: [],
|
||||
|
||||
remove: function(element) {
|
||||
this.drops = this.drops.reject(function(d) { return d.element==$(element) });
|
||||
},
|
||||
|
||||
add: function(element) {
|
||||
element = $(element);
|
||||
var options = Object.extend({
|
||||
greedy: true,
|
||||
hoverclass: null
|
||||
}, arguments[1] || {});
|
||||
|
||||
// cache containers
|
||||
if(options.containment) {
|
||||
options._containers = [];
|
||||
var containment = options.containment;
|
||||
if((typeof containment == 'object') &&
|
||||
(containment.constructor == Array)) {
|
||||
containment.each( function(c) { options._containers.push($(c)) });
|
||||
} else {
|
||||
options._containers.push($(containment));
|
||||
}
|
||||
}
|
||||
|
||||
if(options.accept) options.accept = [options.accept].flatten();
|
||||
|
||||
Element.makePositioned(element); // fix IE
|
||||
options.element = element;
|
||||
|
||||
this.drops.push(options);
|
||||
},
|
||||
|
||||
isContained: function(element, drop) {
|
||||
var parentNode = element.parentNode;
|
||||
return drop._containers.detect(function(c) { return parentNode == c });
|
||||
},
|
||||
|
||||
isAffected: function(point, element, drop) {
|
||||
return (
|
||||
(drop.element!=element) &&
|
||||
((!drop._containers) ||
|
||||
this.isContained(element, drop)) &&
|
||||
((!drop.accept) ||
|
||||
(Element.classNames(element).detect(
|
||||
function(v) { return drop.accept.include(v) } ) )) &&
|
||||
Position.within(drop.element, point[0], point[1]) );
|
||||
},
|
||||
|
||||
deactivate: function(drop) {
|
||||
if(drop.hoverclass)
|
||||
Element.removeClassName(drop.element, drop.hoverclass);
|
||||
this.last_active = null;
|
||||
},
|
||||
|
||||
activate: function(drop) {
|
||||
if(drop.hoverclass)
|
||||
Element.addClassName(drop.element, drop.hoverclass);
|
||||
this.last_active = drop;
|
||||
},
|
||||
|
||||
show: function(point, element) {
|
||||
if(!this.drops.length) return;
|
||||
|
||||
if(this.last_active) this.deactivate(this.last_active);
|
||||
this.drops.each( function(drop) {
|
||||
if(Droppables.isAffected(point, element, drop)) {
|
||||
if(drop.onHover)
|
||||
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
|
||||
if(drop.greedy) {
|
||||
Droppables.activate(drop);
|
||||
throw $break;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
fire: function(event, element) {
|
||||
if(!this.last_active) return;
|
||||
Position.prepare();
|
||||
|
||||
if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
|
||||
if (this.last_active.onDrop)
|
||||
this.last_active.onDrop(element, this.last_active.element, event);
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
if(this.last_active)
|
||||
this.deactivate(this.last_active);
|
||||
}
|
||||
}
|
||||
|
||||
var Draggables = {
|
||||
drags: [],
|
||||
observers: [],
|
||||
|
||||
register: function(draggable) {
|
||||
if(this.drags.length == 0) {
|
||||
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
|
||||
this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
|
||||
this.eventKeypress = this.keyPress.bindAsEventListener(this);
|
||||
|
||||
Event.observe(document, "mouseup", this.eventMouseUp);
|
||||
Event.observe(document, "mousemove", this.eventMouseMove);
|
||||
Event.observe(document, "keypress", this.eventKeypress);
|
||||
}
|
||||
this.drags.push(draggable);
|
||||
},
|
||||
|
||||
unregister: function(draggable) {
|
||||
this.drags = this.drags.reject(function(d) { return d==draggable });
|
||||
if(this.drags.length == 0) {
|
||||
Event.stopObserving(document, "mouseup", this.eventMouseUp);
|
||||
Event.stopObserving(document, "mousemove", this.eventMouseMove);
|
||||
Event.stopObserving(document, "keypress", this.eventKeypress);
|
||||
}
|
||||
},
|
||||
|
||||
activate: function(draggable) {
|
||||
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
|
||||
this.activeDraggable = draggable;
|
||||
},
|
||||
|
||||
deactivate: function(draggbale) {
|
||||
this.activeDraggable = null;
|
||||
},
|
||||
|
||||
updateDrag: function(event) {
|
||||
if(!this.activeDraggable) return;
|
||||
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
||||
// Mozilla-based browsers fire successive mousemove events with
|
||||
// the same coordinates, prevent needless redrawing (moz bug?)
|
||||
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
|
||||
this._lastPointer = pointer;
|
||||
this.activeDraggable.updateDrag(event, pointer);
|
||||
},
|
||||
|
||||
endDrag: function(event) {
|
||||
if(!this.activeDraggable) return;
|
||||
this._lastPointer = null;
|
||||
this.activeDraggable.endDrag(event);
|
||||
},
|
||||
|
||||
keyPress: function(event) {
|
||||
if(this.activeDraggable)
|
||||
this.activeDraggable.keyPress(event);
|
||||
},
|
||||
|
||||
addObserver: function(observer) {
|
||||
this.observers.push(observer);
|
||||
this._cacheObserverCallbacks();
|
||||
},
|
||||
|
||||
removeObserver: function(element) { // element instead of observer fixes mem leaks
|
||||
this.observers = this.observers.reject( function(o) { return o.element==element });
|
||||
this._cacheObserverCallbacks();
|
||||
},
|
||||
|
||||
notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
|
||||
if(this[eventName+'Count'] > 0)
|
||||
this.observers.each( function(o) {
|
||||
if(o[eventName]) o[eventName](eventName, draggable, event);
|
||||
});
|
||||
},
|
||||
|
||||
_cacheObserverCallbacks: function() {
|
||||
['onStart','onEnd','onDrag'].each( function(eventName) {
|
||||
Draggables[eventName+'Count'] = Draggables.observers.select(
|
||||
function(o) { return o[eventName]; }
|
||||
).length;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
var 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) {
|
||||
var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
|
||||
element._revert = new Effect.MoveBy(element, -top_offset, -left_offset, {duration:dur});
|
||||
},
|
||||
endeffect: function(element) {
|
||||
new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0});
|
||||
},
|
||||
zindex: 1000,
|
||||
revert: false,
|
||||
snap: false // false, or xy or [x,y] or function(x,y){ return [x,y] }
|
||||
}, arguments[1] || {});
|
||||
|
||||
this.element = $(element);
|
||||
|
||||
if(options.handle && (typeof options.handle == 'string'))
|
||||
this.handle = Element.childrenWithClassName(this.element, options.handle)[0];
|
||||
if(!this.handle) this.handle = $(options.handle);
|
||||
if(!this.handle) this.handle = this.element;
|
||||
|
||||
Element.makePositioned(this.element); // fix IE
|
||||
|
||||
this.delta = this.currentDelta();
|
||||
this.options = options;
|
||||
this.dragging = false;
|
||||
|
||||
this.eventMouseDown = this.initDrag.bindAsEventListener(this);
|
||||
Event.observe(this.handle, "mousedown", this.eventMouseDown);
|
||||
|
||||
Draggables.register(this);
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
|
||||
Draggables.unregister(this);
|
||||
},
|
||||
|
||||
currentDelta: function() {
|
||||
return([
|
||||
parseInt(this.element.style.left || '0'),
|
||||
parseInt(this.element.style.top || '0')]);
|
||||
},
|
||||
|
||||
initDrag: function(event) {
|
||||
if(Event.isLeftClick(event)) {
|
||||
// abort on form elements, fixes a Firefox issue
|
||||
var src = Event.element(event);
|
||||
if(src.tagName && (
|
||||
src.tagName=='INPUT' ||
|
||||
src.tagName=='SELECT' ||
|
||||
src.tagName=='BUTTON' ||
|
||||
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 pos = Position.cumulativeOffset(this.element);
|
||||
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
|
||||
|
||||
Draggables.activate(this);
|
||||
Event.stop(event);
|
||||
}
|
||||
},
|
||||
|
||||
startDrag: function(event) {
|
||||
this.dragging = true;
|
||||
|
||||
if(this.options.zindex) {
|
||||
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
|
||||
this.element.style.zIndex = this.options.zindex;
|
||||
}
|
||||
|
||||
if(this.options.ghosting) {
|
||||
this._clone = this.element.cloneNode(true);
|
||||
Position.absolutize(this.element);
|
||||
this.element.parentNode.insertBefore(this._clone, this.element);
|
||||
}
|
||||
|
||||
Draggables.notify('onStart', this, event);
|
||||
if(this.options.starteffect) this.options.starteffect(this.element);
|
||||
},
|
||||
|
||||
updateDrag: function(event, pointer) {
|
||||
if(!this.dragging) this.startDrag(event);
|
||||
Position.prepare();
|
||||
Droppables.show(pointer, this.element);
|
||||
Draggables.notify('onDrag', this, event);
|
||||
this.draw(pointer);
|
||||
if(this.options.change) this.options.change(this);
|
||||
|
||||
// fix AppleWebKit rendering
|
||||
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
|
||||
Event.stop(event);
|
||||
},
|
||||
|
||||
finishDrag: function(event, success) {
|
||||
this.dragging = false;
|
||||
|
||||
if(this.options.ghosting) {
|
||||
Position.relativize(this.element);
|
||||
Element.remove(this._clone);
|
||||
this._clone = null;
|
||||
}
|
||||
|
||||
if(success) Droppables.fire(event, this.element);
|
||||
Draggables.notify('onEnd', this, event);
|
||||
|
||||
var revert = this.options.revert;
|
||||
if(revert && typeof revert == 'function') revert = revert(this.element);
|
||||
|
||||
var d = this.currentDelta();
|
||||
if(revert && this.options.reverteffect) {
|
||||
this.options.reverteffect(this.element,
|
||||
d[1]-this.delta[1], d[0]-this.delta[0]);
|
||||
} else {
|
||||
this.delta = d;
|
||||
}
|
||||
|
||||
if(this.options.zindex)
|
||||
this.element.style.zIndex = this.originalZ;
|
||||
|
||||
if(this.options.endeffect)
|
||||
this.options.endeffect(this.element);
|
||||
|
||||
Draggables.deactivate(this);
|
||||
Droppables.reset();
|
||||
},
|
||||
|
||||
keyPress: function(event) {
|
||||
if(!event.keyCode==Event.KEY_ESC) return;
|
||||
this.finishDrag(event, false);
|
||||
Event.stop(event);
|
||||
},
|
||||
|
||||
endDrag: function(event) {
|
||||
if(!this.dragging) return;
|
||||
this.finishDrag(event, true);
|
||||
Event.stop(event);
|
||||
},
|
||||
|
||||
draw: function(point) {
|
||||
var pos = Position.cumulativeOffset(this.element);
|
||||
var d = this.currentDelta();
|
||||
pos[0] -= d[0]; pos[1] -= d[1];
|
||||
|
||||
var p = [0,1].map(function(i){ return (point[i]-pos[i]-this.offset[i]) }.bind(this));
|
||||
|
||||
if(this.options.snap) {
|
||||
if(typeof this.options.snap == 'function') {
|
||||
p = this.options.snap(p[0],p[1]);
|
||||
} else {
|
||||
if(this.options.snap instanceof Array) {
|
||||
p = p.map( function(v, i) {
|
||||
return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this))
|
||||
} else {
|
||||
p = p.map( function(v) {
|
||||
return Math.round(v/this.options.snap)*this.options.snap }.bind(this))
|
||||
}
|
||||
}}
|
||||
|
||||
var style = this.element.style;
|
||||
if((!this.options.constraint) || (this.options.constraint=='horizontal'))
|
||||
style.left = p[0] + "px";
|
||||
if((!this.options.constraint) || (this.options.constraint=='vertical'))
|
||||
style.top = p[1] + "px";
|
||||
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
var 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() {
|
||||
Sortable.unmark();
|
||||
if(this.lastValue != Sortable.serialize(this.element))
|
||||
this.observer(this.element)
|
||||
}
|
||||
}
|
||||
|
||||
var Sortable = {
|
||||
sortables: new Array(),
|
||||
|
||||
options: function(element){
|
||||
element = $(element);
|
||||
return this.sortables.detect(function(s) { return s.element == element });
|
||||
},
|
||||
|
||||
destroy: function(element){
|
||||
element = $(element);
|
||||
this.sortables.findAll(function(s) { return s.element == element }).each(function(s){
|
||||
Draggables.removeObserver(s.element);
|
||||
s.droppables.each(function(d){ Droppables.remove(d) });
|
||||
s.draggables.invoke('destroy');
|
||||
});
|
||||
this.sortables = this.sortables.reject(function(s) { return s.element == element });
|
||||
},
|
||||
|
||||
create: function(element) {
|
||||
element = $(element);
|
||||
var options = Object.extend({
|
||||
element: element,
|
||||
tag: 'li', // assumes li children, override with tag: 'tagname'
|
||||
dropOnEmpty: false,
|
||||
tree: false, // fixme: unimplemented
|
||||
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,
|
||||
ghosting: false,
|
||||
format: null,
|
||||
onChange: Prototype.emptyFunction,
|
||||
onUpdate: Prototype.emptyFunction
|
||||
}, arguments[1] || {});
|
||||
|
||||
// clear any old sortable with same element
|
||||
this.destroy(element);
|
||||
|
||||
// build options for the draggables
|
||||
var options_for_draggable = {
|
||||
revert: true,
|
||||
ghosting: options.ghosting,
|
||||
constraint: options.constraint,
|
||||
handle: options.handle };
|
||||
|
||||
if(options.starteffect)
|
||||
options_for_draggable.starteffect = options.starteffect;
|
||||
|
||||
if(options.reverteffect)
|
||||
options_for_draggable.reverteffect = options.reverteffect;
|
||||
else
|
||||
if(options.ghosting) options_for_draggable.reverteffect = function(element) {
|
||||
element.style.top = 0;
|
||||
element.style.left = 0;
|
||||
};
|
||||
|
||||
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: Sortable.onHover,
|
||||
greedy: !options.dropOnEmpty
|
||||
}
|
||||
|
||||
// fix for gecko engine
|
||||
Element.cleanWhitespace(element);
|
||||
|
||||
options.draggables = [];
|
||||
options.droppables = [];
|
||||
|
||||
// make it so
|
||||
|
||||
// drop on empty handling
|
||||
if(options.dropOnEmpty) {
|
||||
Droppables.add(element,
|
||||
{containment: options.containment, onHover: Sortable.onEmptyHover, greedy: false});
|
||||
options.droppables.push(element);
|
||||
}
|
||||
|
||||
(this.findElements(element, options) || []).each( function(e) {
|
||||
// handles are per-draggable
|
||||
var handle = options.handle ?
|
||||
Element.childrenWithClassName(e, options.handle)[0] : e;
|
||||
options.draggables.push(
|
||||
new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
|
||||
Droppables.add(e, options_for_droppable);
|
||||
options.droppables.push(e);
|
||||
});
|
||||
|
||||
// keep reference
|
||||
this.sortables.push(options);
|
||||
|
||||
// for onupdate
|
||||
Draggables.addObserver(new SortableObserver(element, options.onUpdate));
|
||||
|
||||
},
|
||||
|
||||
// return all suitable-for-sortable elements in a guaranteed order
|
||||
findElements: function(element, options) {
|
||||
if(!element.hasChildNodes()) return null;
|
||||
var elements = [];
|
||||
$A(element.childNodes).each( function(e) {
|
||||
if(e.tagName && e.tagName.toUpperCase()==options.tag.toUpperCase() &&
|
||||
(!options.only || (Element.hasClassName(e, options.only))))
|
||||
elements.push(e);
|
||||
if(options.tree) {
|
||||
var grandchildren = this.findElements(e, options);
|
||||
if(grandchildren) elements.push(grandchildren);
|
||||
}
|
||||
});
|
||||
|
||||
return (elements.length>0 ? elements.flatten() : null);
|
||||
},
|
||||
|
||||
onHover: function(element, dropon, overlap) {
|
||||
if(overlap>0.5) {
|
||||
Sortable.mark(dropon, 'before');
|
||||
if(dropon.previousSibling != element) {
|
||||
var oldParentNode = element.parentNode;
|
||||
element.style.visibility = "hidden"; // fix gecko rendering
|
||||
dropon.parentNode.insertBefore(element, dropon);
|
||||
if(dropon.parentNode!=oldParentNode)
|
||||
Sortable.options(oldParentNode).onChange(element);
|
||||
Sortable.options(dropon.parentNode).onChange(element);
|
||||
}
|
||||
} else {
|
||||
Sortable.mark(dropon, 'after');
|
||||
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)
|
||||
Sortable.options(oldParentNode).onChange(element);
|
||||
Sortable.options(dropon.parentNode).onChange(element);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onEmptyHover: function(element, dropon) {
|
||||
if(element.parentNode!=dropon) {
|
||||
var oldParentNode = element.parentNode;
|
||||
dropon.appendChild(element);
|
||||
Sortable.options(oldParentNode).onChange(element);
|
||||
Sortable.options(dropon).onChange(element);
|
||||
}
|
||||
},
|
||||
|
||||
unmark: function() {
|
||||
if(Sortable._marker) Element.hide(Sortable._marker);
|
||||
},
|
||||
|
||||
mark: function(dropon, position) {
|
||||
// mark on ghosting only
|
||||
var sortable = Sortable.options(dropon.parentNode);
|
||||
if(sortable && !sortable.ghosting) return;
|
||||
|
||||
if(!Sortable._marker) {
|
||||
Sortable._marker = $('dropmarker') || document.createElement('DIV');
|
||||
Element.hide(Sortable._marker);
|
||||
Element.addClassName(Sortable._marker, 'dropmarker');
|
||||
Sortable._marker.style.position = 'absolute';
|
||||
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
|
||||
}
|
||||
var offsets = Position.cumulativeOffset(dropon);
|
||||
Sortable._marker.style.left = offsets[0] + 'px';
|
||||
Sortable._marker.style.top = offsets[1] + 'px';
|
||||
|
||||
if(position=='after')
|
||||
if(sortable.overlap == 'horizontal')
|
||||
Sortable._marker.style.left = (offsets[0]+dropon.clientWidth) + 'px';
|
||||
else
|
||||
Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px';
|
||||
|
||||
Element.show(Sortable._marker);
|
||||
},
|
||||
|
||||
serialize: function(element) {
|
||||
element = $(element);
|
||||
var sortableOptions = this.options(element);
|
||||
var options = Object.extend({
|
||||
tag: sortableOptions.tag,
|
||||
only: sortableOptions.only,
|
||||
name: element.id,
|
||||
format: sortableOptions.format || /^[^_]*_(.*)$/
|
||||
}, arguments[1] || {});
|
||||
return $(this.findElements(element, options) || []).map( function(item) {
|
||||
return (encodeURIComponent(options.name) + "[]=" +
|
||||
encodeURIComponent(item.id.match(options.format) ? item.id.match(options.format)[1] : ''));
|
||||
}).join("&");
|
||||
}
|
||||
}
|
||||
854
issue_relations/public/javascripts/effects.js
vendored
Normal file
854
issue_relations/public/javascripts/effects.js
vendored
Normal file
@@ -0,0 +1,854 @@
|
||||
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||
// Contributors:
|
||||
// Justin Palmer (http://encytemedia.com/)
|
||||
// Mark Pilgrim (http://diveintomark.org/)
|
||||
// Martin Bialasinki
|
||||
//
|
||||
// See scriptaculous.js for full license.
|
||||
|
||||
/* ------------- element ext -------------- */
|
||||
|
||||
// converts rgb() and #xxx to #xxxxxx format,
|
||||
// returns self (or first argument) if not convertable
|
||||
String.prototype.parseColor = function() {
|
||||
var color = '#';
|
||||
if(this.slice(0,4) == 'rgb(') {
|
||||
var cols = this.slice(4,this.length-1).split(',');
|
||||
var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
|
||||
} else {
|
||||
if(this.slice(0,1) == '#') {
|
||||
if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();
|
||||
if(this.length==7) color = this.toLowerCase();
|
||||
}
|
||||
}
|
||||
return(color.length==7 ? color : (arguments[0] || this));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Element.setStyle = function(element, style) {
|
||||
element = $(element);
|
||||
for(k in style) element.style[k.camelize()] = style[k];
|
||||
}
|
||||
|
||||
Element.setContentZoom = function(element, percent) {
|
||||
Element.setStyle(element, {fontSize: (percent/100) + 'em'});
|
||||
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
|
||||
}
|
||||
|
||||
Element.getOpacity = function(element){
|
||||
var opacity;
|
||||
if (opacity = Element.getStyle(element, 'opacity'))
|
||||
return parseFloat(opacity);
|
||||
if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/))
|
||||
if(opacity[1]) return parseFloat(opacity[1]) / 100;
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
Element.setOpacity = function(element, value){
|
||||
element= $(element);
|
||||
if (value == 1){
|
||||
Element.setStyle(element, { opacity:
|
||||
(/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ?
|
||||
0.999999 : null });
|
||||
if(/MSIE/.test(navigator.userAgent))
|
||||
Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});
|
||||
} else {
|
||||
if(value < 0.00001) value = 0;
|
||||
Element.setStyle(element, {opacity: value});
|
||||
if(/MSIE/.test(navigator.userAgent))
|
||||
Element.setStyle(element,
|
||||
{ filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
|
||||
'alpha(opacity='+value*100+')' });
|
||||
}
|
||||
}
|
||||
|
||||
Element.getInlineOpacity = function(element){
|
||||
return $(element).style.opacity || '';
|
||||
}
|
||||
|
||||
Element.childrenWithClassName = function(element, className) {
|
||||
return $A($(element).getElementsByTagName('*')).select(
|
||||
function(c) { return Element.hasClassName(c, className) });
|
||||
}
|
||||
|
||||
Array.prototype.call = function() {
|
||||
var args = arguments;
|
||||
this.each(function(f){ f.apply(this, args) });
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
var Effect = {
|
||||
tagifyText: function(element) {
|
||||
var tagifyStyle = 'position:relative';
|
||||
if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1';
|
||||
element = $(element);
|
||||
$A(element.childNodes).each( function(child) {
|
||||
if(child.nodeType==3) {
|
||||
child.nodeValue.toArray().each( function(character) {
|
||||
element.insertBefore(
|
||||
Builder.node('span',{style: tagifyStyle},
|
||||
character == ' ' ? String.fromCharCode(160) : character),
|
||||
child);
|
||||
});
|
||||
Element.remove(child);
|
||||
}
|
||||
});
|
||||
},
|
||||
multiple: function(element, effect) {
|
||||
var elements;
|
||||
if(((typeof element == 'object') ||
|
||||
(typeof element == 'function')) &&
|
||||
(element.length))
|
||||
elements = element;
|
||||
else
|
||||
elements = $(element).childNodes;
|
||||
|
||||
var options = Object.extend({
|
||||
speed: 0.1,
|
||||
delay: 0.0
|
||||
}, arguments[2] || {});
|
||||
var masterDelay = options.delay;
|
||||
|
||||
$A(elements).each( function(element, index) {
|
||||
new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var 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()/4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/* ------------- core effects ------------- */
|
||||
|
||||
Effect.Queue = {
|
||||
effects: [],
|
||||
_each: function(iterator) {
|
||||
this.effects._each(iterator);
|
||||
},
|
||||
interval: null,
|
||||
add: function(effect) {
|
||||
var timestamp = new Date().getTime();
|
||||
|
||||
switch(effect.options.queue) {
|
||||
case 'front':
|
||||
// move unstarted effects after this effect
|
||||
this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
|
||||
e.startOn += effect.finishOn;
|
||||
e.finishOn += effect.finishOn;
|
||||
});
|
||||
break;
|
||||
case 'end':
|
||||
// start effect after last queued effect has finished
|
||||
timestamp = this.effects.pluck('finishOn').max() || timestamp;
|
||||
break;
|
||||
}
|
||||
|
||||
effect.startOn += timestamp;
|
||||
effect.finishOn += timestamp;
|
||||
this.effects.push(effect);
|
||||
if(!this.interval)
|
||||
this.interval = setInterval(this.loop.bind(this), 40);
|
||||
},
|
||||
remove: function(effect) {
|
||||
this.effects = this.effects.reject(function(e) { return e==effect });
|
||||
if(this.effects.length == 0) {
|
||||
clearInterval(this.interval);
|
||||
this.interval = null;
|
||||
}
|
||||
},
|
||||
loop: function() {
|
||||
var timePos = new Date().getTime();
|
||||
this.effects.invoke('loop', timePos);
|
||||
}
|
||||
}
|
||||
Object.extend(Effect.Queue, Enumerable);
|
||||
|
||||
Effect.Base = function() {};
|
||||
Effect.Base.prototype = {
|
||||
position: null,
|
||||
setOptions: function(options) {
|
||||
this.options = Object.extend({
|
||||
transition: Effect.Transitions.sinoidal,
|
||||
duration: 1.0, // seconds
|
||||
fps: 25.0, // max. 25fps due to Effect.Queue implementation
|
||||
sync: false, // true for combining
|
||||
from: 0.0,
|
||||
to: 1.0,
|
||||
delay: 0.0,
|
||||
queue: 'parallel'
|
||||
}, options || {});
|
||||
},
|
||||
start: function(options) {
|
||||
this.setOptions(options || {});
|
||||
this.currentFrame = 0;
|
||||
this.state = 'idle';
|
||||
this.startOn = this.options.delay*1000;
|
||||
this.finishOn = this.startOn + (this.options.duration*1000);
|
||||
this.event('beforeStart');
|
||||
if(!this.options.sync) Effect.Queue.add(this);
|
||||
},
|
||||
loop: function(timePos) {
|
||||
if(timePos >= this.startOn) {
|
||||
if(timePos >= this.finishOn) {
|
||||
this.render(1.0);
|
||||
this.cancel();
|
||||
this.event('beforeFinish');
|
||||
if(this.finish) this.finish();
|
||||
this.event('afterFinish');
|
||||
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;
|
||||
}
|
||||
}
|
||||
},
|
||||
render: function(pos) {
|
||||
if(this.state == 'idle') {
|
||||
this.state = 'running';
|
||||
this.event('beforeSetup');
|
||||
if(this.setup) this.setup();
|
||||
this.event('afterSetup');
|
||||
}
|
||||
if(this.state == 'running') {
|
||||
if(this.options.transition) pos = this.options.transition(pos);
|
||||
pos *= (this.options.to-this.options.from);
|
||||
pos += this.options.from;
|
||||
this.position = pos;
|
||||
this.event('beforeUpdate');
|
||||
if(this.update) this.update(pos);
|
||||
this.event('afterUpdate');
|
||||
}
|
||||
},
|
||||
cancel: function() {
|
||||
if(!this.options.sync) Effect.Queue.remove(this);
|
||||
this.state = 'finished';
|
||||
},
|
||||
event: function(eventName) {
|
||||
if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
|
||||
if(this.options[eventName]) this.options[eventName](this);
|
||||
},
|
||||
inspect: function() {
|
||||
return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>';
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
this.effects.invoke('render', position);
|
||||
},
|
||||
finish: function(position) {
|
||||
this.effects.each( function(effect) {
|
||||
effect.render(1.0);
|
||||
effect.cancel();
|
||||
effect.event('beforeFinish');
|
||||
if(effect.finish) effect.finish(position);
|
||||
effect.event('afterFinish');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Effect.Opacity = Class.create();
|
||||
Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
|
||||
initialize: function(element) {
|
||||
this.element = $(element);
|
||||
// make this work on IE on elements without 'layout'
|
||||
if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
|
||||
Element.setStyle(this.element, {zoom: 1});
|
||||
var options = Object.extend({
|
||||
from: Element.getOpacity(this.element) || 0.0,
|
||||
to: 1.0
|
||||
}, arguments[1] || {});
|
||||
this.start(options);
|
||||
},
|
||||
update: function(position) {
|
||||
Element.setOpacity(this.element, position);
|
||||
}
|
||||
});
|
||||
|
||||
Effect.MoveBy = Class.create();
|
||||
Object.extend(Object.extend(Effect.MoveBy.prototype, Effect.Base.prototype), {
|
||||
initialize: function(element, toTop, toLeft) {
|
||||
this.element = $(element);
|
||||
this.toTop = toTop;
|
||||
this.toLeft = toLeft;
|
||||
this.start(arguments[3]);
|
||||
},
|
||||
setup: function() {
|
||||
// Bug in Opera: Opera returns the "real" position of a static element or
|
||||
// relative element that does not have top/left explicitly set.
|
||||
// ==> Always set top and left for position relative elements in your stylesheets
|
||||
// (to 0 if you do not need them)
|
||||
Element.makePositioned(this.element);
|
||||
this.originalTop = parseFloat(Element.getStyle(this.element,'top') || '0');
|
||||
this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0');
|
||||
},
|
||||
update: function(position) {
|
||||
Element.setStyle(this.element, {
|
||||
top: this.toTop * position + this.originalTop + 'px',
|
||||
left: this.toLeft * position + this.originalLeft + 'px'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Effect.Scale = Class.create();
|
||||
Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
|
||||
initialize: function(element, percent) {
|
||||
this.element = $(element)
|
||||
var options = Object.extend({
|
||||
scaleX: true,
|
||||
scaleY: true,
|
||||
scaleContent: true,
|
||||
scaleFromCenter: false,
|
||||
scaleMode: 'box', // 'box' or 'contents' or {} with provided values
|
||||
scaleFrom: 100.0,
|
||||
scaleTo: percent
|
||||
}, arguments[2] || {});
|
||||
this.start(options);
|
||||
},
|
||||
setup: function() {
|
||||
this.restoreAfterFinish = this.options.restoreAfterFinish || false;
|
||||
this.elementPositioning = Element.getStyle(this.element,'position');
|
||||
|
||||
this.originalStyle = {};
|
||||
['top','left','width','height','fontSize'].each( function(k) {
|
||||
this.originalStyle[k] = this.element.style[k];
|
||||
}.bind(this));
|
||||
|
||||
this.originalTop = this.element.offsetTop;
|
||||
this.originalLeft = this.element.offsetLeft;
|
||||
|
||||
var fontSize = Element.getStyle(this.element,'font-size') || '100%';
|
||||
['em','px','%'].each( function(fontSizeType) {
|
||||
if(fontSize.indexOf(fontSizeType)>0) {
|
||||
this.fontSize = parseFloat(fontSize);
|
||||
this.fontSizeType = fontSizeType;
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
|
||||
|
||||
this.dims = null;
|
||||
if(this.options.scaleMode=='box')
|
||||
this.dims = [this.element.offsetHeight, this.element.offsetWidth];
|
||||
if(/^content/.test(this.options.scaleMode))
|
||||
this.dims = [this.element.scrollHeight, this.element.scrollWidth];
|
||||
if(!this.dims)
|
||||
this.dims = [this.options.scaleMode.originalHeight,
|
||||
this.options.scaleMode.originalWidth];
|
||||
},
|
||||
update: function(position) {
|
||||
var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
|
||||
if(this.options.scaleContent && this.fontSize)
|
||||
Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType });
|
||||
this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
|
||||
},
|
||||
finish: function(position) {
|
||||
if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle);
|
||||
},
|
||||
setDimensions: function(height, width) {
|
||||
var d = {};
|
||||
if(this.options.scaleX) d.width = width + 'px';
|
||||
if(this.options.scaleY) d.height = height + 'px';
|
||||
if(this.options.scaleFromCenter) {
|
||||
var topd = (height - this.dims[0])/2;
|
||||
var leftd = (width - this.dims[1])/2;
|
||||
if(this.elementPositioning == 'absolute') {
|
||||
if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
|
||||
if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
|
||||
} else {
|
||||
if(this.options.scaleY) d.top = -topd + 'px';
|
||||
if(this.options.scaleX) d.left = -leftd + 'px';
|
||||
}
|
||||
}
|
||||
Element.setStyle(this.element, d);
|
||||
}
|
||||
});
|
||||
|
||||
Effect.Highlight = Class.create();
|
||||
Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
|
||||
initialize: function(element) {
|
||||
this.element = $(element);
|
||||
var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
|
||||
this.start(options);
|
||||
},
|
||||
setup: function() {
|
||||
// Prevent executing on elements not in the layout flow
|
||||
if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; }
|
||||
// Disable background image during the effect
|
||||
this.oldStyle = {
|
||||
backgroundImage: Element.getStyle(this.element, 'background-image') };
|
||||
Element.setStyle(this.element, {backgroundImage: 'none'});
|
||||
if(!this.options.endcolor)
|
||||
this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff');
|
||||
if(!this.options.restorecolor)
|
||||
this.options.restorecolor = Element.getStyle(this.element, 'background-color');
|
||||
// init color calculations
|
||||
this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
|
||||
this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
|
||||
},
|
||||
update: function(position) {
|
||||
Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){
|
||||
return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
|
||||
},
|
||||
finish: function() {
|
||||
Element.setStyle(this.element, Object.extend(this.oldStyle, {
|
||||
backgroundColor: this.options.restorecolor
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
Effect.ScrollTo = Class.create();
|
||||
Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
|
||||
initialize: function(element) {
|
||||
this.element = $(element);
|
||||
this.start(arguments[1] || {});
|
||||
},
|
||||
setup: function() {
|
||||
Position.prepare();
|
||||
var offsets = Position.cumulativeOffset(this.element);
|
||||
if(this.options.offset) offsets[1] += this.options.offset;
|
||||
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;
|
||||
},
|
||||
update: function(position) {
|
||||
Position.prepare();
|
||||
window.scrollTo(Position.deltaX,
|
||||
this.scrollStart + (position*this.delta));
|
||||
}
|
||||
});
|
||||
|
||||
/* ------------- combination effects ------------- */
|
||||
|
||||
Effect.Fade = function(element) {
|
||||
var oldOpacity = Element.getInlineOpacity(element);
|
||||
var options = Object.extend({
|
||||
from: Element.getOpacity(element) || 1.0,
|
||||
to: 0.0,
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
if(effect.options.to!=0) return;
|
||||
hide(effect.element);
|
||||
setStyle(effect.element, {opacity: oldOpacity}); }}
|
||||
}, arguments[1] || {});
|
||||
return new Effect.Opacity(element,options);
|
||||
}
|
||||
|
||||
Effect.Appear = function(element) {
|
||||
var options = Object.extend({
|
||||
from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0),
|
||||
to: 1.0,
|
||||
beforeSetup: function(effect) { with(Element) {
|
||||
setOpacity(effect.element, effect.options.from);
|
||||
show(effect.element); }}
|
||||
}, arguments[1] || {});
|
||||
return new Effect.Opacity(element,options);
|
||||
}
|
||||
|
||||
Effect.Puff = function(element) {
|
||||
element = $(element);
|
||||
var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') };
|
||||
return new Effect.Parallel(
|
||||
[ new Effect.Scale(element, 200,
|
||||
{ sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
|
||||
new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
|
||||
Object.extend({ duration: 1.0,
|
||||
beforeSetupInternal: function(effect) { with(Element) {
|
||||
setStyle(effect.effects[0].element, {position: 'absolute'}); }},
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
hide(effect.effects[0].element);
|
||||
setStyle(effect.effects[0].element, oldStyle); }}
|
||||
}, arguments[1] || {})
|
||||
);
|
||||
}
|
||||
|
||||
Effect.BlindUp = function(element) {
|
||||
element = $(element);
|
||||
Element.makeClipping(element);
|
||||
return new Effect.Scale(element, 0,
|
||||
Object.extend({ scaleContent: false,
|
||||
scaleX: false,
|
||||
restoreAfterFinish: true,
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
[hide, undoClipping].call(effect.element); }}
|
||||
}, arguments[1] || {})
|
||||
);
|
||||
}
|
||||
|
||||
Effect.BlindDown = function(element) {
|
||||
element = $(element);
|
||||
var oldHeight = Element.getStyle(element, 'height');
|
||||
var elementDimensions = Element.getDimensions(element);
|
||||
return new Effect.Scale(element, 100,
|
||||
Object.extend({ scaleContent: false,
|
||||
scaleX: false,
|
||||
scaleFrom: 0,
|
||||
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
|
||||
restoreAfterFinish: true,
|
||||
afterSetup: function(effect) { with(Element) {
|
||||
makeClipping(effect.element);
|
||||
setStyle(effect.element, {height: '0px'});
|
||||
show(effect.element);
|
||||
}},
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
undoClipping(effect.element);
|
||||
setStyle(effect.element, {height: oldHeight});
|
||||
}}
|
||||
}, arguments[1] || {})
|
||||
);
|
||||
}
|
||||
|
||||
Effect.SwitchOff = function(element) {
|
||||
element = $(element);
|
||||
var oldOpacity = Element.getInlineOpacity(element);
|
||||
return new Effect.Appear(element, {
|
||||
duration: 0.4,
|
||||
from: 0,
|
||||
transition: Effect.Transitions.flicker,
|
||||
afterFinishInternal: function(effect) {
|
||||
new Effect.Scale(effect.element, 1, {
|
||||
duration: 0.3, scaleFromCenter: true,
|
||||
scaleX: false, scaleContent: false, restoreAfterFinish: true,
|
||||
beforeSetup: function(effect) { with(Element) {
|
||||
[makePositioned,makeClipping].call(effect.element);
|
||||
}},
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
[hide,undoClipping,undoPositioned].call(effect.element);
|
||||
setStyle(effect.element, {opacity: oldOpacity});
|
||||
}}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Effect.DropOut = function(element) {
|
||||
element = $(element);
|
||||
var oldStyle = {
|
||||
top: Element.getStyle(element, 'top'),
|
||||
left: Element.getStyle(element, 'left'),
|
||||
opacity: Element.getInlineOpacity(element) };
|
||||
return new Effect.Parallel(
|
||||
[ new Effect.MoveBy(element, 100, 0, { sync: true }),
|
||||
new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
|
||||
Object.extend(
|
||||
{ duration: 0.5,
|
||||
beforeSetup: function(effect) { with(Element) {
|
||||
makePositioned(effect.effects[0].element); }},
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
[hide, undoPositioned].call(effect.effects[0].element);
|
||||
setStyle(effect.effects[0].element, oldStyle); }}
|
||||
}, arguments[1] || {}));
|
||||
}
|
||||
|
||||
Effect.Shake = function(element) {
|
||||
element = $(element);
|
||||
var oldStyle = {
|
||||
top: Element.getStyle(element, 'top'),
|
||||
left: Element.getStyle(element, 'left') };
|
||||
return new Effect.MoveBy(element, 0, 20,
|
||||
{ duration: 0.05, afterFinishInternal: function(effect) {
|
||||
new Effect.MoveBy(effect.element, 0, -40,
|
||||
{ duration: 0.1, afterFinishInternal: function(effect) {
|
||||
new Effect.MoveBy(effect.element, 0, 40,
|
||||
{ duration: 0.1, afterFinishInternal: function(effect) {
|
||||
new Effect.MoveBy(effect.element, 0, -40,
|
||||
{ duration: 0.1, afterFinishInternal: function(effect) {
|
||||
new Effect.MoveBy(effect.element, 0, 40,
|
||||
{ duration: 0.1, afterFinishInternal: function(effect) {
|
||||
new Effect.MoveBy(effect.element, 0, -20,
|
||||
{ duration: 0.05, afterFinishInternal: function(effect) { with(Element) {
|
||||
undoPositioned(effect.element);
|
||||
setStyle(effect.element, oldStyle);
|
||||
}}}) }}) }}) }}) }}) }});
|
||||
}
|
||||
|
||||
Effect.SlideDown = function(element) {
|
||||
element = $(element);
|
||||
Element.cleanWhitespace(element);
|
||||
// SlideDown need to have the content of the element wrapped in a container element with fixed height!
|
||||
var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
|
||||
var elementDimensions = Element.getDimensions(element);
|
||||
return new Effect.Scale(element, 100, Object.extend({
|
||||
scaleContent: false,
|
||||
scaleX: false,
|
||||
scaleFrom: 0,
|
||||
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
|
||||
restoreAfterFinish: true,
|
||||
afterSetup: function(effect) { with(Element) {
|
||||
makePositioned(effect.element);
|
||||
makePositioned(effect.element.firstChild);
|
||||
if(window.opera) setStyle(effect.element, {top: ''});
|
||||
makeClipping(effect.element);
|
||||
setStyle(effect.element, {height: '0px'});
|
||||
show(element); }},
|
||||
afterUpdateInternal: function(effect) { with(Element) {
|
||||
setStyle(effect.element.firstChild, {bottom:
|
||||
(effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
undoClipping(effect.element);
|
||||
undoPositioned(effect.element.firstChild);
|
||||
undoPositioned(effect.element);
|
||||
setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
|
||||
}, arguments[1] || {})
|
||||
);
|
||||
}
|
||||
|
||||
Effect.SlideUp = function(element) {
|
||||
element = $(element);
|
||||
Element.cleanWhitespace(element);
|
||||
var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
|
||||
return new Effect.Scale(element, 0,
|
||||
Object.extend({ scaleContent: false,
|
||||
scaleX: false,
|
||||
scaleMode: 'box',
|
||||
scaleFrom: 100,
|
||||
restoreAfterFinish: true,
|
||||
beforeStartInternal: function(effect) { with(Element) {
|
||||
makePositioned(effect.element);
|
||||
makePositioned(effect.element.firstChild);
|
||||
if(window.opera) setStyle(effect.element, {top: ''});
|
||||
makeClipping(effect.element);
|
||||
show(element); }},
|
||||
afterUpdateInternal: function(effect) { with(Element) {
|
||||
setStyle(effect.element.firstChild, {bottom:
|
||||
(effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
[hide, undoClipping].call(effect.element);
|
||||
undoPositioned(effect.element.firstChild);
|
||||
undoPositioned(effect.element);
|
||||
setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
|
||||
}, arguments[1] || {})
|
||||
);
|
||||
}
|
||||
|
||||
// Bug in opera makes the TD containing this element expand for a instance after finish
|
||||
Effect.Squish = function(element) {
|
||||
return new Effect.Scale(element, window.opera ? 1 : 0,
|
||||
{ restoreAfterFinish: true,
|
||||
beforeSetup: function(effect) { with(Element) {
|
||||
makeClipping(effect.element); }},
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
hide(effect.element);
|
||||
undoClipping(effect.element); }}
|
||||
});
|
||||
}
|
||||
|
||||
Effect.Grow = function(element) {
|
||||
element = $(element);
|
||||
var options = Object.extend({
|
||||
direction: 'center',
|
||||
moveTransistion: Effect.Transitions.sinoidal,
|
||||
scaleTransition: Effect.Transitions.sinoidal,
|
||||
opacityTransition: Effect.Transitions.full
|
||||
}, arguments[1] || {});
|
||||
var oldStyle = {
|
||||
top: element.style.top,
|
||||
left: element.style.left,
|
||||
height: element.style.height,
|
||||
width: element.style.width,
|
||||
opacity: Element.getInlineOpacity(element) };
|
||||
|
||||
var dims = Element.getDimensions(element);
|
||||
var initialMoveX, initialMoveY;
|
||||
var moveX, moveY;
|
||||
|
||||
switch (options.direction) {
|
||||
case 'top-left':
|
||||
initialMoveX = initialMoveY = moveX = moveY = 0;
|
||||
break;
|
||||
case 'top-right':
|
||||
initialMoveX = dims.width;
|
||||
initialMoveY = moveY = 0;
|
||||
moveX = -dims.width;
|
||||
break;
|
||||
case 'bottom-left':
|
||||
initialMoveX = moveX = 0;
|
||||
initialMoveY = dims.height;
|
||||
moveY = -dims.height;
|
||||
break;
|
||||
case 'bottom-right':
|
||||
initialMoveX = dims.width;
|
||||
initialMoveY = dims.height;
|
||||
moveX = -dims.width;
|
||||
moveY = -dims.height;
|
||||
break;
|
||||
case 'center':
|
||||
initialMoveX = dims.width / 2;
|
||||
initialMoveY = dims.height / 2;
|
||||
moveX = -dims.width / 2;
|
||||
moveY = -dims.height / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
return new Effect.MoveBy(element, initialMoveY, initialMoveX, {
|
||||
duration: 0.01,
|
||||
beforeSetup: function(effect) { with(Element) {
|
||||
hide(effect.element);
|
||||
makeClipping(effect.element);
|
||||
makePositioned(effect.element);
|
||||
}},
|
||||
afterFinishInternal: function(effect) {
|
||||
new Effect.Parallel(
|
||||
[ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
|
||||
new Effect.MoveBy(effect.element, moveY, moveX, { sync: true, transition: options.moveTransition }),
|
||||
new Effect.Scale(effect.element, 100, {
|
||||
scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
|
||||
sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
|
||||
], Object.extend({
|
||||
beforeSetup: function(effect) { with(Element) {
|
||||
setStyle(effect.effects[0].element, {height: '0px'});
|
||||
show(effect.effects[0].element); }},
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
[undoClipping, undoPositioned].call(effect.effects[0].element);
|
||||
setStyle(effect.effects[0].element, oldStyle); }}
|
||||
}, options)
|
||||
)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Effect.Shrink = function(element) {
|
||||
element = $(element);
|
||||
var options = Object.extend({
|
||||
direction: 'center',
|
||||
moveTransistion: Effect.Transitions.sinoidal,
|
||||
scaleTransition: Effect.Transitions.sinoidal,
|
||||
opacityTransition: Effect.Transitions.none
|
||||
}, arguments[1] || {});
|
||||
var oldStyle = {
|
||||
top: element.style.top,
|
||||
left: element.style.left,
|
||||
height: element.style.height,
|
||||
width: element.style.width,
|
||||
opacity: Element.getInlineOpacity(element) };
|
||||
|
||||
var dims = Element.getDimensions(element);
|
||||
var moveX, moveY;
|
||||
|
||||
switch (options.direction) {
|
||||
case 'top-left':
|
||||
moveX = moveY = 0;
|
||||
break;
|
||||
case 'top-right':
|
||||
moveX = dims.width;
|
||||
moveY = 0;
|
||||
break;
|
||||
case 'bottom-left':
|
||||
moveX = 0;
|
||||
moveY = dims.height;
|
||||
break;
|
||||
case 'bottom-right':
|
||||
moveX = dims.width;
|
||||
moveY = dims.height;
|
||||
break;
|
||||
case 'center':
|
||||
moveX = dims.width / 2;
|
||||
moveY = dims.height / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
return new Effect.Parallel(
|
||||
[ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
|
||||
new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
|
||||
new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: options.moveTransition })
|
||||
], Object.extend({
|
||||
beforeStartInternal: function(effect) { with(Element) {
|
||||
[makePositioned, makeClipping].call(effect.effects[0].element) }},
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
[hide, undoClipping, undoPositioned].call(effect.effects[0].element);
|
||||
setStyle(effect.effects[0].element, oldStyle); }}
|
||||
}, options)
|
||||
);
|
||||
}
|
||||
|
||||
Effect.Pulsate = function(element) {
|
||||
element = $(element);
|
||||
var options = arguments[1] || {};
|
||||
var oldOpacity = Element.getInlineOpacity(element);
|
||||
var transition = options.transition || Effect.Transitions.sinoidal;
|
||||
var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
|
||||
reverser.bind(transition);
|
||||
return new Effect.Opacity(element,
|
||||
Object.extend(Object.extend({ duration: 3.0, from: 0,
|
||||
afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); }
|
||||
}, options), {transition: reverser}));
|
||||
}
|
||||
|
||||
Effect.Fold = function(element) {
|
||||
element = $(element);
|
||||
var oldStyle = {
|
||||
top: element.style.top,
|
||||
left: element.style.left,
|
||||
width: element.style.width,
|
||||
height: element.style.height };
|
||||
Element.makeClipping(element);
|
||||
return new Effect.Scale(element, 5, Object.extend({
|
||||
scaleContent: false,
|
||||
scaleX: false,
|
||||
afterFinishInternal: function(effect) {
|
||||
new Effect.Scale(element, 1, {
|
||||
scaleContent: false,
|
||||
scaleY: false,
|
||||
afterFinishInternal: function(effect) { with(Element) {
|
||||
[hide, undoClipping].call(effect.element);
|
||||
setStyle(effect.element, oldStyle);
|
||||
}} });
|
||||
}}, arguments[1] || {}));
|
||||
}
|
||||
440
issue_relations/public/javascripts/jstoolbar.js
Normal file
440
issue_relations/public/javascripts/jstoolbar.js
Normal file
@@ -0,0 +1,440 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* This file is part of DotClear.
|
||||
* Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All
|
||||
* rights reserved.
|
||||
*
|
||||
* DotClear is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DotClear is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DotClear; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/* Modified by JP LANG for textile formatting */
|
||||
|
||||
function jsToolBar(textarea) {
|
||||
if (!document.createElement) { return; }
|
||||
|
||||
if (!textarea) { return; }
|
||||
|
||||
if ((typeof(document["selection"]) == "undefined")
|
||||
&& (typeof(textarea["setSelectionRange"]) == "undefined")) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.textarea = textarea;
|
||||
|
||||
this.editor = document.createElement('div');
|
||||
this.editor.className = 'jstEditor';
|
||||
|
||||
this.textarea.parentNode.insertBefore(this.editor,this.textarea);
|
||||
this.editor.appendChild(this.textarea);
|
||||
|
||||
this.toolbar = document.createElement("div");
|
||||
this.toolbar.className = 'jstElements';
|
||||
this.editor.parentNode.insertBefore(this.toolbar,this.editor);
|
||||
|
||||
// Dragable resizing (only for gecko)
|
||||
if (this.editor.addEventListener)
|
||||
{
|
||||
this.handle = document.createElement('div');
|
||||
this.handle.className = 'jstHandle';
|
||||
var dragStart = this.resizeDragStart;
|
||||
var This = this;
|
||||
this.handle.addEventListener('mousedown',function(event) { dragStart.call(This,event); },false);
|
||||
// fix memory leak in Firefox (bug #241518)
|
||||
window.addEventListener('unload',function() {
|
||||
var del = This.handle.parentNode.removeChild(This.handle);
|
||||
delete(This.handle);
|
||||
},false);
|
||||
|
||||
this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling);
|
||||
}
|
||||
|
||||
this.context = null;
|
||||
this.toolNodes = {}; // lorsque la toolbar est dessinée , cet objet est garni
|
||||
// de raccourcis vers les éléments DOM correspondants aux outils.
|
||||
}
|
||||
|
||||
function jsButton(title, fn, scope, className) {
|
||||
this.title = title || null;
|
||||
this.fn = fn || function(){};
|
||||
this.scope = scope || null;
|
||||
this.className = className || null;
|
||||
}
|
||||
jsButton.prototype.draw = function() {
|
||||
if (!this.scope) return null;
|
||||
|
||||
var button = document.createElement('button');
|
||||
button.setAttribute('type','button');
|
||||
if (this.className) button.className = this.className;
|
||||
button.title = this.title;
|
||||
var span = document.createElement('span');
|
||||
span.appendChild(document.createTextNode(this.title));
|
||||
button.appendChild(span);
|
||||
|
||||
if (this.icon != undefined) {
|
||||
button.style.backgroundImage = 'url('+this.icon+')';
|
||||
}
|
||||
if (typeof(this.fn) == 'function') {
|
||||
var This = this;
|
||||
button.onclick = function() { try { This.fn.apply(This.scope, arguments) } catch (e) {} return false; };
|
||||
}
|
||||
return button;
|
||||
}
|
||||
|
||||
function jsSpace(id) {
|
||||
this.id = id || null;
|
||||
this.width = null;
|
||||
}
|
||||
jsSpace.prototype.draw = function() {
|
||||
var span = document.createElement('span');
|
||||
if (this.id) span.id = this.id;
|
||||
span.appendChild(document.createTextNode(String.fromCharCode(160)));
|
||||
span.className = 'jstSpacer';
|
||||
if (this.width) span.style.marginRight = this.width+'px';
|
||||
|
||||
return span;
|
||||
}
|
||||
|
||||
function jsCombo(title, options, scope, fn, className) {
|
||||
this.title = title || null;
|
||||
this.options = options || null;
|
||||
this.scope = scope || null;
|
||||
this.fn = fn || function(){};
|
||||
this.className = className || null;
|
||||
}
|
||||
jsCombo.prototype.draw = function() {
|
||||
if (!this.scope || !this.options) return null;
|
||||
|
||||
var select = document.createElement('select');
|
||||
if (this.className) select.className = className;
|
||||
select.title = this.title;
|
||||
|
||||
for (var o in this.options) {
|
||||
//var opt = this.options[o];
|
||||
var option = document.createElement('option');
|
||||
option.value = o;
|
||||
option.appendChild(document.createTextNode(this.options[o]));
|
||||
select.appendChild(option);
|
||||
}
|
||||
|
||||
var This = this;
|
||||
select.onchange = function() {
|
||||
try {
|
||||
This.fn.call(This.scope, this.value);
|
||||
} catch (e) { alert(e); }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return select;
|
||||
}
|
||||
|
||||
|
||||
jsToolBar.prototype = {
|
||||
base_url: '',
|
||||
mode: 'wiki',
|
||||
elements: {},
|
||||
|
||||
getMode: function() {
|
||||
return this.mode;
|
||||
},
|
||||
|
||||
setMode: function(mode) {
|
||||
this.mode = mode || 'wiki';
|
||||
},
|
||||
|
||||
switchMode: function(mode) {
|
||||
mode = mode || 'wiki';
|
||||
this.draw(mode);
|
||||
},
|
||||
|
||||
button: function(toolName) {
|
||||
var tool = this.elements[toolName];
|
||||
if (typeof tool.fn[this.mode] != 'function') return null;
|
||||
var b = new jsButton(tool.title, tool.fn[this.mode], this, 'jstb_'+toolName);
|
||||
if (tool.icon != undefined) b.icon = tool.icon;
|
||||
return b;
|
||||
},
|
||||
space: function(toolName) {
|
||||
var tool = new jsSpace(toolName)
|
||||
if (this.elements[toolName].width !== undefined)
|
||||
tool.width = this.elements[toolName].width;
|
||||
return tool;
|
||||
},
|
||||
combo: function(toolName) {
|
||||
var tool = this.elements[toolName];
|
||||
var length = tool[this.mode].list.length;
|
||||
|
||||
if (typeof tool[this.mode].fn != 'function' || length == 0) {
|
||||
return null;
|
||||
} else {
|
||||
var options = {};
|
||||
for (var i=0; i < length; i++) {
|
||||
var opt = tool[this.mode].list[i];
|
||||
options[opt] = tool.options[opt];
|
||||
}
|
||||
return new jsCombo(tool.title, options, this, tool[this.mode].fn);
|
||||
}
|
||||
},
|
||||
draw: function(mode) {
|
||||
this.setMode(mode);
|
||||
|
||||
// Empty toolbar
|
||||
while (this.toolbar.hasChildNodes()) {
|
||||
this.toolbar.removeChild(this.toolbar.firstChild)
|
||||
}
|
||||
this.toolNodes = {}; // vide les raccourcis DOM/**/
|
||||
|
||||
// Draw toolbar elements
|
||||
var b, tool, newTool;
|
||||
|
||||
for (var i in this.elements) {
|
||||
b = this.elements[i];
|
||||
|
||||
var disabled =
|
||||
b.type == undefined || b.type == ''
|
||||
|| (b.disabled != undefined && b.disabled)
|
||||
|| (b.context != undefined && b.context != null && b.context != this.context);
|
||||
|
||||
if (!disabled && typeof this[b.type] == 'function') {
|
||||
tool = this[b.type](i);
|
||||
if (tool) newTool = tool.draw();
|
||||
if (newTool) {
|
||||
this.toolNodes[i] = newTool; //mémorise l'accès DOM pour usage éventuel ultérieur
|
||||
this.toolbar.appendChild(newTool);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
singleTag: function(stag,etag) {
|
||||
stag = stag || null;
|
||||
etag = etag || stag;
|
||||
|
||||
if (!stag || !etag) { return; }
|
||||
|
||||
this.encloseSelection(stag,etag);
|
||||
},
|
||||
|
||||
encloseSelection: function(prefix, suffix, fn) {
|
||||
this.textarea.focus();
|
||||
|
||||
prefix = prefix || '';
|
||||
suffix = suffix || '';
|
||||
|
||||
var start, end, sel, scrollPos, subst, res;
|
||||
|
||||
if (typeof(document["selection"]) != "undefined") {
|
||||
sel = document.selection.createRange().text;
|
||||
} else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
|
||||
start = this.textarea.selectionStart;
|
||||
end = this.textarea.selectionEnd;
|
||||
scrollPos = this.textarea.scrollTop;
|
||||
sel = this.textarea.value.substring(start, end);
|
||||
}
|
||||
|
||||
if (sel.match(/ $/)) { // exclude ending space char, if any
|
||||
sel = sel.substring(0, sel.length - 1);
|
||||
suffix = suffix + " ";
|
||||
}
|
||||
|
||||
if (typeof(fn) == 'function') {
|
||||
res = (sel) ? fn.call(this,sel) : fn('');
|
||||
} else {
|
||||
res = (sel) ? sel : '';
|
||||
}
|
||||
|
||||
subst = prefix + res + suffix;
|
||||
|
||||
if (typeof(document["selection"]) != "undefined") {
|
||||
var range = document.selection.createRange().text = subst;
|
||||
this.textarea.caretPos -= suffix.length;
|
||||
} else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
|
||||
this.textarea.value = this.textarea.value.substring(0, start) + subst +
|
||||
this.textarea.value.substring(end);
|
||||
if (sel) {
|
||||
this.textarea.setSelectionRange(start + subst.length, start + subst.length);
|
||||
} else {
|
||||
this.textarea.setSelectionRange(start + prefix.length, start + prefix.length);
|
||||
}
|
||||
this.textarea.scrollTop = scrollPos;
|
||||
}
|
||||
},
|
||||
|
||||
stripBaseURL: function(url) {
|
||||
if (this.base_url != '') {
|
||||
var pos = url.indexOf(this.base_url);
|
||||
if (pos == 0) {
|
||||
url = url.substr(this.base_url.length);
|
||||
}
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
};
|
||||
|
||||
/** Resizer
|
||||
-------------------------------------------------------- */
|
||||
jsToolBar.prototype.resizeSetStartH = function() {
|
||||
this.dragStartH = this.textarea.offsetHeight + 0;
|
||||
};
|
||||
jsToolBar.prototype.resizeDragStart = function(event) {
|
||||
var This = this;
|
||||
this.dragStartY = event.clientY;
|
||||
this.resizeSetStartH();
|
||||
document.addEventListener('mousemove', this.dragMoveHdlr=function(event){This.resizeDragMove(event);}, false);
|
||||
document.addEventListener('mouseup', this.dragStopHdlr=function(event){This.resizeDragStop(event);}, false);
|
||||
};
|
||||
|
||||
jsToolBar.prototype.resizeDragMove = function(event) {
|
||||
this.textarea.style.height = (this.dragStartH+event.clientY-this.dragStartY)+'px';
|
||||
};
|
||||
|
||||
jsToolBar.prototype.resizeDragStop = function(event) {
|
||||
document.removeEventListener('mousemove', this.dragMoveHdlr, false);
|
||||
document.removeEventListener('mouseup', this.dragStopHdlr, false);
|
||||
};
|
||||
|
||||
// Elements definition ------------------------------------
|
||||
|
||||
// strong
|
||||
jsToolBar.prototype.elements.strong = {
|
||||
type: 'button',
|
||||
title: 'Strong emphasis',
|
||||
fn: {
|
||||
wiki: function() { this.singleTag('*') }
|
||||
}
|
||||
}
|
||||
|
||||
// em
|
||||
jsToolBar.prototype.elements.em = {
|
||||
type: 'button',
|
||||
title: 'Emphasis',
|
||||
fn: {
|
||||
wiki: function() { this.singleTag("_") }
|
||||
}
|
||||
}
|
||||
|
||||
// ins
|
||||
jsToolBar.prototype.elements.ins = {
|
||||
type: 'button',
|
||||
title: 'Inserted',
|
||||
fn: {
|
||||
wiki: function() { this.singleTag('+') }
|
||||
}
|
||||
}
|
||||
|
||||
// del
|
||||
jsToolBar.prototype.elements.del = {
|
||||
type: 'button',
|
||||
title: 'Deleted',
|
||||
fn: {
|
||||
wiki: function() { this.singleTag('-') }
|
||||
}
|
||||
}
|
||||
|
||||
// quote
|
||||
//jsToolBar.prototype.elements.quote = {
|
||||
// type: 'button',
|
||||
// title: 'Inline quote',
|
||||
// fn: {
|
||||
// wiki: function() { this.singleTag('{{','}}') }
|
||||
// }
|
||||
//}
|
||||
|
||||
// code
|
||||
jsToolBar.prototype.elements.code = {
|
||||
type: 'button',
|
||||
title: 'Code',
|
||||
fn: {
|
||||
wiki: function() { this.singleTag('@') }
|
||||
}
|
||||
}
|
||||
|
||||
// spacer
|
||||
//jsToolBar.prototype.elements.space1 = {type: 'space'}
|
||||
|
||||
// br
|
||||
//jsToolBar.prototype.elements.br = {
|
||||
// type: 'button',
|
||||
// title: 'Line break',
|
||||
// fn: {
|
||||
// wiki: function() { this.encloseSelection("%%%\n",'') }
|
||||
// }
|
||||
//}
|
||||
|
||||
// spacer
|
||||
jsToolBar.prototype.elements.space2 = {type: 'space'}
|
||||
|
||||
// ul
|
||||
jsToolBar.prototype.elements.ul = {
|
||||
type: 'button',
|
||||
title: 'Unordered list',
|
||||
fn: {
|
||||
wiki: function() {
|
||||
this.encloseSelection('','',function(str) {
|
||||
str = str.replace(/\r/g,'');
|
||||
return '* '+str.replace(/\n/g,"\n* ");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ol
|
||||
jsToolBar.prototype.elements.ol = {
|
||||
type: 'button',
|
||||
title: 'Ordered list',
|
||||
fn: {
|
||||
wiki: function() {
|
||||
this.encloseSelection('','',function(str) {
|
||||
str = str.replace(/\r/g,'');
|
||||
return '# '+str.replace(/\n/g,"\n# ");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// spacer
|
||||
jsToolBar.prototype.elements.space3 = {type: 'space'}
|
||||
|
||||
// link
|
||||
jsToolBar.prototype.elements.link = {
|
||||
type: 'button',
|
||||
title: 'Link',
|
||||
fn: {},
|
||||
href_prompt: 'Please give page URL:',
|
||||
hreflang_prompt: 'Language of this page:',
|
||||
default_hreflang: '',
|
||||
prompt: function(href,hreflang) {
|
||||
href = href || '';
|
||||
hreflang = hreflang || this.elements.link.default_hreflang;
|
||||
|
||||
href = window.prompt(this.elements.link.href_prompt,href);
|
||||
if (!href) { return false; }
|
||||
|
||||
hreflang = ""
|
||||
|
||||
return { href: this.stripBaseURL(href), hreflang: hreflang };
|
||||
}
|
||||
}
|
||||
|
||||
jsToolBar.prototype.elements.link.fn.wiki = function() {
|
||||
var link = this.elements.link.prompt.call(this);
|
||||
if (link) {
|
||||
var stag = '"';
|
||||
var etag = '":'+link.href;
|
||||
this.encloseSelection(stag,etag);
|
||||
}
|
||||
};
|
||||
556
issue_relations/public/javascripts/menu.js
Normal file
556
issue_relations/public/javascripts/menu.js
Normal file
@@ -0,0 +1,556 @@
|
||||
//*****************************************************************************
|
||||
// Do not remove this notice.
|
||||
//
|
||||
// Copyright 2000-2004 by Mike Hall.
|
||||
// See http://www.brainjar.com for terms of use.
|
||||
//*****************************************************************************
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Emulation de la fonction push pour IE5.0
|
||||
//----------------------------------------------------------------------------
|
||||
if(!Array.prototype.push){Array.prototype.push=function(){for(var i=0;i<arguments.length;i++)this[this.length]=arguments[i];};};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Code to determine the browser and version.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function Browser() {
|
||||
|
||||
var ua, s, i;
|
||||
|
||||
this.isIE = false; // Internet Explorer
|
||||
this.isOP = false; // Opera
|
||||
this.isNS = false; // Netscape
|
||||
this.version = null;
|
||||
//-- debut ajout ci ----
|
||||
this.isIE5mac = false; // Internet Explorer 5 mac
|
||||
//-- fin ajout ci ----
|
||||
|
||||
ua = navigator.userAgent;
|
||||
|
||||
//-- debut ajout ci ----
|
||||
if (ua.indexOf("Opera")==-1 && ua.indexOf("MSIE 5")>-1 && ua.indexOf("Mac")>-1) {
|
||||
this.isIE5mac = true;
|
||||
this.version = "";
|
||||
return;
|
||||
}
|
||||
//-- fin ajout ci ----
|
||||
|
||||
s = "Opera";
|
||||
if ((i = ua.indexOf(s)) >= 0) {
|
||||
this.isOP = true;
|
||||
this.version = parseFloat(ua.substr(i + s.length));
|
||||
return;
|
||||
}
|
||||
|
||||
s = "Netscape6/";
|
||||
if ((i = ua.indexOf(s)) >= 0) {
|
||||
this.isNS = true;
|
||||
this.version = parseFloat(ua.substr(i + s.length));
|
||||
return;
|
||||
}
|
||||
|
||||
// Treat any other "Gecko" browser as Netscape 6.1.
|
||||
|
||||
s = "Gecko";
|
||||
if ((i = ua.indexOf(s)) >= 0) {
|
||||
this.isNS = true;
|
||||
this.version = 6.1;
|
||||
return;
|
||||
}
|
||||
|
||||
s = "MSIE";
|
||||
if ((i = ua.indexOf(s))) {
|
||||
this.isIE = true;
|
||||
this.version = parseFloat(ua.substr(i + s.length));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var browser = new Browser();
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Code for handling the menu bar and active button.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
var activeButton = null;
|
||||
|
||||
|
||||
function buttonClick(event, menuId) {
|
||||
|
||||
var button;
|
||||
|
||||
// Get the target button element.
|
||||
|
||||
if (browser.isIE)
|
||||
button = window.event.srcElement;
|
||||
else
|
||||
button = event.currentTarget;
|
||||
|
||||
// Blur focus from the link to remove that annoying outline.
|
||||
|
||||
button.blur();
|
||||
|
||||
// Associate the named menu to this button if not already done.
|
||||
// Additionally, initialize menu display.
|
||||
|
||||
if (button.menu == null) {
|
||||
button.menu = document.getElementById(menuId);
|
||||
if (button.menu.isInitialized == null)
|
||||
menuInit(button.menu);
|
||||
}
|
||||
|
||||
// Set mouseout event handler for the button, if not already done.
|
||||
|
||||
if (button.onmouseout == null)
|
||||
button.onmouseout = buttonOrMenuMouseout;
|
||||
|
||||
// Exit if this button is the currently active one.
|
||||
|
||||
if (button == activeButton)
|
||||
return false;
|
||||
|
||||
// Reset the currently active button, if any.
|
||||
|
||||
if (activeButton != null)
|
||||
resetButton(activeButton);
|
||||
|
||||
// Activate this button, unless it was the currently active one.
|
||||
|
||||
if (button != activeButton) {
|
||||
depressButton(button);
|
||||
activeButton = button;
|
||||
}
|
||||
else
|
||||
activeButton = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function buttonMouseover(event, menuId) {
|
||||
|
||||
var button;
|
||||
//-- debut ajout ci ----
|
||||
if (!browser.isIE5mac) {
|
||||
//-- fin ajout ci ----
|
||||
|
||||
//-- debut ajout ci ----
|
||||
cicacheselect();
|
||||
//-- fin ajout ci ----
|
||||
|
||||
// Activates this button's menu if no other is currently active.
|
||||
|
||||
if (activeButton == null) {
|
||||
buttonClick(event, menuId);
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the target button element.
|
||||
|
||||
if (browser.isIE)
|
||||
button = window.event.srcElement;
|
||||
else
|
||||
button = event.currentTarget;
|
||||
|
||||
// If any other button menu is active, make this one active instead.
|
||||
|
||||
if (activeButton != null && activeButton != button)
|
||||
buttonClick(event, menuId);
|
||||
//-- debut ajout ci ----
|
||||
}
|
||||
//-- fin ajout ci ----
|
||||
|
||||
}
|
||||
|
||||
function depressButton(button) {
|
||||
|
||||
var x, y;
|
||||
|
||||
// Update the button's style class to make it look like it's
|
||||
// depressed.
|
||||
|
||||
button.className += " menuButtonActive";
|
||||
|
||||
// Set mouseout event handler for the button, if not already done.
|
||||
|
||||
if (button.onmouseout == null)
|
||||
button.onmouseout = buttonOrMenuMouseout;
|
||||
if (button.menu.onmouseout == null)
|
||||
button.menu.onmouseout = buttonOrMenuMouseout;
|
||||
|
||||
// Position the associated drop down menu under the button and
|
||||
// show it.
|
||||
|
||||
x = getPageOffsetLeft(button);
|
||||
y = getPageOffsetTop(button) + button.offsetHeight - 1;
|
||||
|
||||
// For IE, adjust position.
|
||||
|
||||
if (browser.isIE) {
|
||||
x += button.offsetParent.clientLeft;
|
||||
y += button.offsetParent.clientTop;
|
||||
}
|
||||
|
||||
button.menu.style.left = x + "px";
|
||||
button.menu.style.top = y + "px";0
|
||||
button.menu.style.visibility = "visible";
|
||||
}
|
||||
|
||||
function resetButton(button) {
|
||||
|
||||
// Restore the button's style class.
|
||||
|
||||
removeClassName(button, "menuButtonActive");
|
||||
|
||||
// Hide the button's menu, first closing any sub menus.
|
||||
|
||||
if (button.menu != null) {
|
||||
closeSubMenu(button.menu);
|
||||
button.menu.style.visibility = "hidden";
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Code to handle the menus and sub menus.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function menuMouseover(event) {
|
||||
|
||||
var menu;
|
||||
//-- debut ajout ci ----
|
||||
if (!browser.isIE5mac) {
|
||||
//-- fin ajout ci ----
|
||||
//-- debut ajout ci ----
|
||||
cicacheselect();
|
||||
//-- fin ajout ci ----
|
||||
|
||||
// Find the target menu element.
|
||||
if (browser.isIE)
|
||||
menu = getContainerWith(window.event.srcElement, "DIV", "menu");
|
||||
else
|
||||
menu = event.currentTarget;
|
||||
|
||||
// Close any active sub menu.
|
||||
|
||||
if (menu.activeItem != null)
|
||||
closeSubMenu(menu);
|
||||
//-- debut ajout ci ----
|
||||
}
|
||||
//-- fin ajout ci ----
|
||||
}
|
||||
|
||||
function menuItemMouseover(event, menuId) {
|
||||
|
||||
var item, menu, x, y;
|
||||
//-- debut ajout ci ----
|
||||
cicacheselect();
|
||||
//-- fin ajout ci ----
|
||||
|
||||
// Find the target item element and its parent menu element.
|
||||
|
||||
if (browser.isIE)
|
||||
item = getContainerWith(window.event.srcElement, "A", "menuItem");
|
||||
else
|
||||
item = event.currentTarget;
|
||||
menu = getContainerWith(item, "DIV", "menu");
|
||||
|
||||
// Close any active sub menu and mark this one as active.
|
||||
|
||||
if (menu.activeItem != null)
|
||||
closeSubMenu(menu);
|
||||
menu.activeItem = item;
|
||||
|
||||
// Highlight the item element.
|
||||
|
||||
item.className += " menuItemHighlight";
|
||||
|
||||
// Initialize the sub menu, if not already done.
|
||||
|
||||
if (item.subMenu == null) {
|
||||
item.subMenu = document.getElementById(menuId);
|
||||
if (item.subMenu.isInitialized == null)
|
||||
menuInit(item.subMenu);
|
||||
}
|
||||
|
||||
// Set mouseout event handler for the sub menu, if not already done.
|
||||
|
||||
if (item.subMenu.onmouseout == null)
|
||||
item.subMenu.onmouseout = buttonOrMenuMouseout;
|
||||
|
||||
// Get position for submenu based on the menu item.
|
||||
|
||||
x = getPageOffsetLeft(item) + item.offsetWidth;
|
||||
y = getPageOffsetTop(item);
|
||||
|
||||
// Adjust position to fit in view.
|
||||
|
||||
var maxX, maxY;
|
||||
|
||||
if (browser.isIE) {
|
||||
maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) +
|
||||
(document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
|
||||
maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) +
|
||||
(document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
|
||||
}
|
||||
if (browser.isOP) {
|
||||
maxX = document.documentElement.scrollLeft + window.innerWidth;
|
||||
maxY = document.documentElement.scrollTop + window.innerHeight;
|
||||
}
|
||||
if (browser.isNS) {
|
||||
maxX = window.scrollX + window.innerWidth;
|
||||
maxY = window.scrollY + window.innerHeight;
|
||||
}
|
||||
maxX -= item.subMenu.offsetWidth;
|
||||
maxY -= item.subMenu.offsetHeight;
|
||||
|
||||
if (x > maxX)
|
||||
x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
|
||||
+ (menu.offsetWidth - item.offsetWidth));
|
||||
y = Math.max(0, Math.min(y, maxY));
|
||||
|
||||
// Position and show the sub menu.
|
||||
|
||||
item.subMenu.style.left = x + "px";
|
||||
item.subMenu.style.top = y + "px";
|
||||
item.subMenu.style.visibility = "visible";
|
||||
|
||||
// Stop the event from bubbling.
|
||||
|
||||
if (browser.isIE)
|
||||
window.event.cancelBubble = true;
|
||||
else
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
function closeSubMenu(menu) {
|
||||
|
||||
if (menu == null || menu.activeItem == null)
|
||||
return;
|
||||
|
||||
// Recursively close any sub menus.
|
||||
|
||||
if (menu.activeItem.subMenu != null) {
|
||||
closeSubMenu(menu.activeItem.subMenu);
|
||||
menu.activeItem.subMenu.style.visibility = "hidden";
|
||||
menu.activeItem.subMenu = null;
|
||||
}
|
||||
removeClassName(menu.activeItem, "menuItemHighlight");
|
||||
menu.activeItem = null;
|
||||
}
|
||||
|
||||
|
||||
function buttonOrMenuMouseout(event) {
|
||||
|
||||
var el;
|
||||
|
||||
// If there is no active button, exit.
|
||||
|
||||
if (activeButton == null)
|
||||
return;
|
||||
|
||||
// Find the element the mouse is moving to.
|
||||
|
||||
if (browser.isIE)
|
||||
el = window.event.toElement;
|
||||
else if (event.relatedTarget != null)
|
||||
el = (event.relatedTarget.tagName ? event.relatedTarget : event.relatedTarget.parentNode);
|
||||
|
||||
// If the element is not part of a menu, reset the active button.
|
||||
|
||||
if (getContainerWith(el, "DIV", "menu") == null) {
|
||||
resetButton(activeButton);
|
||||
activeButton = null;
|
||||
//-- debut ajout ci ----
|
||||
cimontreselect();
|
||||
//-- fin ajout ci ----
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Code to initialize menus.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function menuInit(menu) {
|
||||
|
||||
var itemList, spanList;
|
||||
var textEl, arrowEl;
|
||||
var itemWidth;
|
||||
var w, dw;
|
||||
var i, j;
|
||||
|
||||
// For IE, replace arrow characters.
|
||||
|
||||
if (browser.isIE) {
|
||||
menu.style.lineHeight = "2.5ex";
|
||||
spanList = menu.getElementsByTagName("SPAN");
|
||||
for (i = 0; i < spanList.length; i++)
|
||||
if (hasClassName(spanList[i], "menuItemArrow")) {
|
||||
spanList[i].style.fontFamily = "Webdings";
|
||||
spanList[i].firstChild.nodeValue = "4";
|
||||
}
|
||||
}
|
||||
|
||||
// Find the width of a menu item.
|
||||
|
||||
itemList = menu.getElementsByTagName("A");
|
||||
if (itemList.length > 0)
|
||||
itemWidth = itemList[0].offsetWidth;
|
||||
else
|
||||
return;
|
||||
|
||||
// For items with arrows, add padding to item text to make the
|
||||
// arrows flush right.
|
||||
|
||||
for (i = 0; i < itemList.length; i++) {
|
||||
spanList = itemList[i].getElementsByTagName("SPAN");
|
||||
textEl = null;
|
||||
arrowEl = null;
|
||||
for (j = 0; j < spanList.length; j++) {
|
||||
if (hasClassName(spanList[j], "menuItemText"))
|
||||
textEl = spanList[j];
|
||||
if (hasClassName(spanList[j], "menuItemArrow"))
|
||||
arrowEl = spanList[j];
|
||||
}
|
||||
if (textEl != null && arrowEl != null) {
|
||||
textEl.style.paddingRight = (itemWidth
|
||||
- (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
|
||||
// For Opera, remove the negative right margin to fix a display bug.
|
||||
if (browser.isOP)
|
||||
arrowEl.style.marginRight = "0px";
|
||||
}
|
||||
}
|
||||
|
||||
// Fix IE hover problem by setting an explicit width on first item of
|
||||
// the menu.
|
||||
|
||||
if (browser.isIE) {
|
||||
w = itemList[0].offsetWidth;
|
||||
itemList[0].style.width = w + "px";
|
||||
dw = itemList[0].offsetWidth - w;
|
||||
w -= dw;
|
||||
itemList[0].style.width = w + "px";
|
||||
}
|
||||
|
||||
// Mark menu as initialized.
|
||||
|
||||
menu.isInitialized = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// General utility functions.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function getContainerWith(node, tagName, className) {
|
||||
|
||||
// Starting with the given node, find the nearest containing element
|
||||
// with the specified tag name and style class.
|
||||
|
||||
while (node != null) {
|
||||
if (node.tagName != null && node.tagName == tagName &&
|
||||
hasClassName(node, className))
|
||||
return node;
|
||||
node = node.parentNode;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function hasClassName(el, name) {
|
||||
|
||||
var i, list;
|
||||
|
||||
// Return true if the given element currently has the given class
|
||||
// name.
|
||||
|
||||
list = el.className.split(" ");
|
||||
for (i = 0; i < list.length; i++)
|
||||
if (list[i] == name)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function removeClassName(el, name) {
|
||||
|
||||
var i, curList, newList;
|
||||
|
||||
if (el.className == null)
|
||||
return;
|
||||
|
||||
// Remove the given class name from the element's className property.
|
||||
|
||||
newList = new Array();
|
||||
curList = el.className.split(" ");
|
||||
for (i = 0; i < curList.length; i++)
|
||||
if (curList[i] != name)
|
||||
newList.push(curList[i]);
|
||||
el.className = newList.join(" ");
|
||||
}
|
||||
|
||||
function getPageOffsetLeft(el) {
|
||||
|
||||
var x;
|
||||
|
||||
// Return the x coordinate of an element relative to the page.
|
||||
|
||||
x = el.offsetLeft;
|
||||
if (el.offsetParent != null)
|
||||
x += getPageOffsetLeft(el.offsetParent);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
function getPageOffsetTop(el) {
|
||||
|
||||
var y;
|
||||
|
||||
// Return the x coordinate of an element relative to the page.
|
||||
|
||||
y = el.offsetTop;
|
||||
if (el.offsetParent != null)
|
||||
y += getPageOffsetTop(el.offsetParent);
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
//-- debut ajout ci ----
|
||||
function cicacheselect(){
|
||||
if (browser.isIE) {
|
||||
oSelects = document.getElementsByTagName('SELECT');
|
||||
if (oSelects.length > 0) {
|
||||
for (i = 0; i < oSelects.length; i++) {
|
||||
oSlt = oSelects[i];
|
||||
if (oSlt.style.visibility != 'hidden') {oSlt.style.visibility = 'hidden';}
|
||||
}
|
||||
}
|
||||
oSelects = document.getElementsByName('masquable');
|
||||
if (oSelects.length > 0) {
|
||||
for (i = 0; i < oSelects.length; i++) {
|
||||
oSlt = oSelects[i];
|
||||
if (oSlt.style.visibility != 'hidden') {oSlt.style.visibility = 'hidden';}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function cimontreselect(){
|
||||
if (browser.isIE) {
|
||||
oSelects = document.getElementsByTagName('SELECT');
|
||||
if (oSelects.length > 0) {
|
||||
for (i = 0; i < oSelects.length; i++) {
|
||||
oSlt = oSelects[i];
|
||||
if (oSlt.style.visibility != 'visible') {oSlt.style.visibility = 'visible';}
|
||||
}
|
||||
}
|
||||
oSelects = document.getElementsByName('masquable');
|
||||
if (oSelects.length > 0) {
|
||||
for (i = 0; i < oSelects.length; i++) {
|
||||
oSlt = oSelects[i];
|
||||
if (oSlt.style.visibility != 'visible') {oSlt.style.visibility = 'visible';}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-- fin ajout ci ----
|
||||
1785
issue_relations/public/javascripts/prototype.js
vendored
Normal file
1785
issue_relations/public/javascripts/prototype.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user