maj de scriptaculous 1.8
This commit is contained in:
parent
73cbf7914b
commit
3c34acb5b3
@ -1,4 +1,4 @@
|
|||||||
// script.aculo.us builder.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
|
// script.aculo.us builder.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
|
||||||
|
|
||||||
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
//
|
//
|
||||||
|
|||||||
813
htdocs/includes/scriptaculous/src/controls.js
vendored
813
htdocs/includes/scriptaculous/src/controls.js
vendored
@ -1,4 +1,4 @@
|
|||||||
// script.aculo.us controls.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
|
// script.aculo.us controls.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
|
||||||
|
|
||||||
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
|
// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
|
||||||
@ -35,6 +35,8 @@
|
|||||||
// enables autocompletion on multiple tokens. This is most
|
// enables autocompletion on multiple tokens. This is most
|
||||||
// useful when one of the tokens is \n (a newline), as it
|
// useful when one of the tokens is \n (a newline), as it
|
||||||
// allows smart autocompletion after linebreaks.
|
// allows smart autocompletion after linebreaks.
|
||||||
|
//
|
||||||
|
// vim:expandtab ts=8 sw=2
|
||||||
|
|
||||||
if(typeof Effect == 'undefined')
|
if(typeof Effect == 'undefined')
|
||||||
throw("controls.js requires including script.aculo.us' effects.js library");
|
throw("controls.js requires including script.aculo.us' effects.js library");
|
||||||
@ -51,6 +53,7 @@ Autocompleter.Base.prototype = {
|
|||||||
this.active = false;
|
this.active = false;
|
||||||
this.index = 0;
|
this.index = 0;
|
||||||
this.entryCount = 0;
|
this.entryCount = 0;
|
||||||
|
this.oldElementValue = this.element.value;
|
||||||
|
|
||||||
if(this.setOptions)
|
if(this.setOptions)
|
||||||
this.setOptions(options);
|
this.setOptions(options);
|
||||||
@ -77,6 +80,9 @@ Autocompleter.Base.prototype = {
|
|||||||
|
|
||||||
if(typeof(this.options.tokens) == 'string')
|
if(typeof(this.options.tokens) == 'string')
|
||||||
this.options.tokens = new Array(this.options.tokens);
|
this.options.tokens = new Array(this.options.tokens);
|
||||||
|
// Force carriage returns as token delimiters anyway
|
||||||
|
if (!this.options.tokens.include('\n'))
|
||||||
|
this.options.tokens.push('\n');
|
||||||
|
|
||||||
this.observer = null;
|
this.observer = null;
|
||||||
|
|
||||||
@ -86,12 +92,6 @@ Autocompleter.Base.prototype = {
|
|||||||
|
|
||||||
Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
|
Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
|
||||||
Event.observe(this.element, 'keypress', this.onKeyPress.bindAsEventListener(this));
|
Event.observe(this.element, 'keypress', this.onKeyPress.bindAsEventListener(this));
|
||||||
|
|
||||||
// Turn autocomplete back on when the user leaves the page, so that the
|
|
||||||
// field's value will be remembered on Mozilla-based browsers.
|
|
||||||
Event.observe(window, 'beforeunload', function(){
|
|
||||||
element.setAttribute('autocomplete', 'on');
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function() {
|
show: function() {
|
||||||
@ -250,16 +250,17 @@ Autocompleter.Base.prototype = {
|
|||||||
} else
|
} else
|
||||||
value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
|
value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
|
||||||
|
|
||||||
var lastTokenPos = this.findLastToken();
|
var bounds = this.getTokenBounds();
|
||||||
if (lastTokenPos != -1) {
|
if (bounds[0] != -1) {
|
||||||
var newValue = this.element.value.substr(0, lastTokenPos + 1);
|
var newValue = this.element.value.substr(0, bounds[0]);
|
||||||
var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/);
|
var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/);
|
||||||
if (whitespace)
|
if (whitespace)
|
||||||
newValue += whitespace[0];
|
newValue += whitespace[0];
|
||||||
this.element.value = newValue + value;
|
this.element.value = newValue + value + this.element.value.substr(bounds[1]);
|
||||||
} else {
|
} else {
|
||||||
this.element.value = value;
|
this.element.value = value;
|
||||||
}
|
}
|
||||||
|
this.oldElementValue = this.element.value;
|
||||||
this.element.focus();
|
this.element.focus();
|
||||||
|
|
||||||
if (this.options.afterUpdateElement)
|
if (this.options.afterUpdateElement)
|
||||||
@ -303,35 +304,46 @@ Autocompleter.Base.prototype = {
|
|||||||
|
|
||||||
onObserverEvent: function() {
|
onObserverEvent: function() {
|
||||||
this.changed = false;
|
this.changed = false;
|
||||||
|
this.tokenBounds = null;
|
||||||
if(this.getToken().length>=this.options.minChars) {
|
if(this.getToken().length>=this.options.minChars) {
|
||||||
this.getUpdatedChoices();
|
this.getUpdatedChoices();
|
||||||
} else {
|
} else {
|
||||||
this.active = false;
|
this.active = false;
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
|
this.oldElementValue = this.element.value;
|
||||||
},
|
},
|
||||||
|
|
||||||
getToken: function() {
|
getToken: function() {
|
||||||
var tokenPos = this.findLastToken();
|
var bounds = this.getTokenBounds();
|
||||||
if (tokenPos != -1)
|
return this.element.value.substring(bounds[0], bounds[1]).strip();
|
||||||
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() {
|
getTokenBounds: function() {
|
||||||
var lastTokenPos = -1;
|
if (null != this.tokenBounds) return this.tokenBounds;
|
||||||
|
var value = this.element.value;
|
||||||
|
if (value.strip().empty()) return [-1, 0];
|
||||||
|
var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue);
|
||||||
|
var offset = (diff == this.oldElementValue.length ? 1 : 0);
|
||||||
|
var prevTokenPos = -1, nextTokenPos = value.length;
|
||||||
|
var tp;
|
||||||
|
for (var index = 0, l = this.options.tokens.length; index < l; ++index) {
|
||||||
|
tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1);
|
||||||
|
if (tp > prevTokenPos) prevTokenPos = tp;
|
||||||
|
tp = value.indexOf(this.options.tokens[index], diff + offset);
|
||||||
|
if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp;
|
||||||
|
}
|
||||||
|
return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (var i=0; i<this.options.tokens.length; i++) {
|
Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {
|
||||||
var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]);
|
var boundary = Math.min(newS.length, oldS.length);
|
||||||
if (thisTokenPos > lastTokenPos)
|
for (var index = 0; index < boundary; ++index)
|
||||||
lastTokenPos = thisTokenPos;
|
if (newS[index] != oldS[index])
|
||||||
}
|
return index;
|
||||||
return lastTokenPos;
|
return boundary;
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
Ajax.Autocompleter = Class.create();
|
Ajax.Autocompleter = Class.create();
|
||||||
Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
|
Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
|
||||||
@ -460,9 +472,8 @@ Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// AJAX in-place editor
|
// AJAX in-place editor and collection editor
|
||||||
//
|
// Full rewrite by Christophe Porteneuve <tdd@tddsworld.com> (April 2007).
|
||||||
// see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
|
|
||||||
|
|
||||||
// Use this if you notice weird scrolling problems on some browsers,
|
// 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
|
// the DOM might be a bit confused when this gets called so do this
|
||||||
@ -474,380 +485,466 @@ Field.scrollFreeActivate = function(field) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ajax.InPlaceEditor = Class.create();
|
Ajax.InPlaceEditor = Class.create();
|
||||||
Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
|
Object.extend(Ajax.InPlaceEditor, {
|
||||||
Ajax.InPlaceEditor.prototype = {
|
DefaultOptions: {
|
||||||
initialize: function(element, url, options) {
|
ajaxOptions: { },
|
||||||
this.url = url;
|
autoRows: 3, // Use when multi-line w/ rows == 1
|
||||||
this.element = $(element);
|
cancelControl: 'link', // 'link'|'button'|false
|
||||||
|
cancelText: 'cancel',
|
||||||
this.options = Object.extend({
|
clickToEditText: 'Click to edit',
|
||||||
paramName: "value",
|
externalControl: null, // id|elt
|
||||||
okButton: true,
|
externalControlOnly: false,
|
||||||
okLink: false,
|
fieldPostCreation: 'activate', // 'activate'|'focus'|false
|
||||||
okText: "ok",
|
formClassName: 'inplaceeditor-form',
|
||||||
cancelButton: false,
|
formId: null, // id|elt
|
||||||
cancelLink: true,
|
highlightColor: '#ffff99',
|
||||||
cancelText: "cancel",
|
highlightEndColor: '#ffffff',
|
||||||
textBeforeControls: '',
|
hoverClassName: '',
|
||||||
textBetweenControls: '',
|
htmlResponse: true,
|
||||||
|
loadingClassName: 'inplaceeditor-loading',
|
||||||
|
loadingText: 'Loading...',
|
||||||
|
okControl: 'button', // 'link'|'button'|false
|
||||||
|
okText: 'ok',
|
||||||
|
paramName: 'value',
|
||||||
|
rows: 1, // If 1 and multi-line, uses autoRows
|
||||||
|
savingClassName: 'inplaceeditor-saving',
|
||||||
|
savingText: 'Saving...',
|
||||||
|
size: 0,
|
||||||
|
stripLoadedTextTags: false,
|
||||||
|
submitOnBlur: false,
|
||||||
textAfterControls: '',
|
textAfterControls: '',
|
||||||
savingText: "Saving...",
|
textBeforeControls: '',
|
||||||
clickToEditText: "Click to edit",
|
textBetweenControls: ''
|
||||||
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());
|
|
||||||
},
|
},
|
||||||
|
DefaultCallbacks: {
|
||||||
callback: function(form) {
|
callback: function(form) {
|
||||||
return Form.serialize(form);
|
return Form.serialize(form);
|
||||||
},
|
},
|
||||||
handleLineBreaks: true,
|
onComplete: function(transport, element) {
|
||||||
loadingText: 'Loading...',
|
// For backward compatibility, this one is bound to the IPE, and passes
|
||||||
savingClassName: 'inplaceeditor-saving',
|
// the element directly. It was too often customized, so we don't break it.
|
||||||
loadingClassName: 'inplaceeditor-loading',
|
new Effect.Highlight(element, {
|
||||||
formClassName: 'inplaceeditor-form',
|
startcolor: this.options.highlightColor, keepBackgroundImage: true });
|
||||||
highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
|
},
|
||||||
highlightendcolor: "#FFFFFF",
|
onEnterEditMode: null,
|
||||||
externalControl: null,
|
onEnterHover: function(ipe) {
|
||||||
submitOnBlur: false,
|
ipe.element.style.backgroundColor = ipe.options.highlightColor;
|
||||||
ajaxOptions: {},
|
if (ipe._effect)
|
||||||
evalScripts: false
|
ipe._effect.cancel();
|
||||||
}, options || {});
|
},
|
||||||
|
onFailure: function(transport, ipe) {
|
||||||
|
alert('Error communication with the server: ' + transport.responseText.stripTags());
|
||||||
|
},
|
||||||
|
onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls.
|
||||||
|
onLeaveEditMode: null,
|
||||||
|
onLeaveHover: function(ipe) {
|
||||||
|
ipe._effect = new Effect.Highlight(ipe.element, {
|
||||||
|
startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor,
|
||||||
|
restorecolor: ipe._originalBackground, keepBackgroundImage: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Listeners: {
|
||||||
|
click: 'enterEditMode',
|
||||||
|
keydown: 'checkForEscapeOrReturn',
|
||||||
|
mouseover: 'enterHover',
|
||||||
|
mouseout: 'leaveHover'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Ajax.InPlaceEditor.prototype = {
|
||||||
|
initialize: function(element, url, options) {
|
||||||
|
this.url = url;
|
||||||
|
this.element = element = $(element);
|
||||||
|
this.prepareOptions();
|
||||||
|
this._controls = { };
|
||||||
|
arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!!
|
||||||
|
Object.extend(this.options, options || { });
|
||||||
if (!this.options.formId && this.element.id) {
|
if (!this.options.formId && this.element.id) {
|
||||||
this.options.formId = this.element.id + "-inplaceeditor";
|
this.options.formId = this.element.id + '-inplaceeditor';
|
||||||
if ($(this.options.formId)) {
|
if ($(this.options.formId))
|
||||||
// there's already a form with that name, don't specify an id
|
this.options.formId = '';
|
||||||
this.options.formId = null;
|
|
||||||
}
|
}
|
||||||
}
|
if (this.options.externalControl)
|
||||||
|
|
||||||
if (this.options.externalControl) {
|
|
||||||
this.options.externalControl = $(this.options.externalControl);
|
this.options.externalControl = $(this.options.externalControl);
|
||||||
}
|
if (!this.options.externalControl)
|
||||||
|
this.options.externalControlOnly = false;
|
||||||
this.originalBackground = Element.getStyle(this.element, 'background-color');
|
this._originalBackground = this.element.getStyle('background-color') || 'transparent';
|
||||||
if (!this.originalBackground) {
|
|
||||||
this.originalBackground = "transparent";
|
|
||||||
}
|
|
||||||
|
|
||||||
this.element.title = this.options.clickToEditText;
|
this.element.title = this.options.clickToEditText;
|
||||||
|
this._boundCancelHandler = this.handleFormCancellation.bind(this);
|
||||||
this.onclickListener = this.enterEditMode.bindAsEventListener(this);
|
this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this);
|
||||||
this.mouseoverListener = this.enterHover.bindAsEventListener(this);
|
this._boundFailureHandler = this.handleAJAXFailure.bind(this);
|
||||||
this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
|
this._boundSubmitHandler = this.handleFormSubmission.bind(this);
|
||||||
Event.observe(this.element, 'click', this.onclickListener);
|
this._boundWrapperHandler = this.wrapUp.bind(this);
|
||||||
Event.observe(this.element, 'mouseover', this.mouseoverListener);
|
this.registerListeners();
|
||||||
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) {
|
checkForEscapeOrReturn: function(e) {
|
||||||
if (this.saving) return;
|
if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return;
|
||||||
if (this.editing) return;
|
if (Event.KEY_ESC == e.keyCode)
|
||||||
this.editing = true;
|
this.handleFormCancellation(e);
|
||||||
this.onEnterEditMode();
|
else if (Event.KEY_RETURN == e.keyCode)
|
||||||
if (this.options.externalControl) {
|
this.handleFormSubmission(e);
|
||||||
Element.hide(this.options.externalControl);
|
|
||||||
}
|
|
||||||
Element.hide(this.element);
|
|
||||||
this.createForm();
|
|
||||||
this.element.parentNode.insertBefore(this.form, this.element);
|
|
||||||
if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField);
|
|
||||||
// stop the event to avoid a page refresh in Safari
|
|
||||||
if (evt) {
|
|
||||||
Event.stop(evt);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
},
|
||||||
createForm: function() {
|
createControl: function(mode, handler, extraClasses) {
|
||||||
this.form = document.createElement("form");
|
var control = this.options[mode + 'Control'];
|
||||||
this.form.id = this.options.formId;
|
var text = this.options[mode + 'Text'];
|
||||||
Element.addClassName(this.form, this.options.formClassName)
|
if ('button' == control) {
|
||||||
this.form.onsubmit = this.onSubmit.bind(this);
|
var btn = document.createElement('input');
|
||||||
|
btn.type = 'submit';
|
||||||
this.createEditField();
|
btn.value = text;
|
||||||
|
btn.className = 'editor_' + mode + '_button';
|
||||||
if (this.options.textarea) {
|
if ('cancel' == mode)
|
||||||
var br = document.createElement("br");
|
btn.onclick = this._boundCancelHandler;
|
||||||
this.form.appendChild(br);
|
this._form.appendChild(btn);
|
||||||
|
this._controls[mode] = btn;
|
||||||
|
} else if ('link' == control) {
|
||||||
|
var link = document.createElement('a');
|
||||||
|
link.href = '#';
|
||||||
|
link.appendChild(document.createTextNode(text));
|
||||||
|
link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler;
|
||||||
|
link.className = 'editor_' + mode + '_link';
|
||||||
|
if (extraClasses)
|
||||||
|
link.className += ' ' + extraClasses;
|
||||||
|
this._form.appendChild(link);
|
||||||
|
this._controls[mode] = link;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.options.textBeforeControls)
|
|
||||||
this.form.appendChild(document.createTextNode(this.options.textBeforeControls));
|
|
||||||
|
|
||||||
if (this.options.okButton) {
|
|
||||||
var okButton = document.createElement("input");
|
|
||||||
okButton.type = "submit";
|
|
||||||
okButton.value = this.options.okText;
|
|
||||||
okButton.className = 'editor_ok_button';
|
|
||||||
this.form.appendChild(okButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.options.okLink) {
|
|
||||||
var okLink = document.createElement("a");
|
|
||||||
okLink.href = "#";
|
|
||||||
okLink.appendChild(document.createTextNode(this.options.okText));
|
|
||||||
okLink.onclick = this.onSubmit.bind(this);
|
|
||||||
okLink.className = 'editor_ok_link';
|
|
||||||
this.form.appendChild(okLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.options.textBetweenControls &&
|
|
||||||
(this.options.okLink || this.options.okButton) &&
|
|
||||||
(this.options.cancelLink || this.options.cancelButton))
|
|
||||||
this.form.appendChild(document.createTextNode(this.options.textBetweenControls));
|
|
||||||
|
|
||||||
if (this.options.cancelButton) {
|
|
||||||
var cancelButton = document.createElement("input");
|
|
||||||
cancelButton.type = "submit";
|
|
||||||
cancelButton.value = this.options.cancelText;
|
|
||||||
cancelButton.onclick = this.onclickCancel.bind(this);
|
|
||||||
cancelButton.className = 'editor_cancel_button';
|
|
||||||
this.form.appendChild(cancelButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.options.cancelLink) {
|
|
||||||
var cancelLink = document.createElement("a");
|
|
||||||
cancelLink.href = "#";
|
|
||||||
cancelLink.appendChild(document.createTextNode(this.options.cancelText));
|
|
||||||
cancelLink.onclick = this.onclickCancel.bind(this);
|
|
||||||
cancelLink.className = 'editor_cancel editor_cancel_link';
|
|
||||||
this.form.appendChild(cancelLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.options.textAfterControls)
|
|
||||||
this.form.appendChild(document.createTextNode(this.options.textAfterControls));
|
|
||||||
},
|
|
||||||
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() {
|
createEditField: function() {
|
||||||
var text;
|
var text = (this.options.loadTextURL ? this.options.loadingText : this.getText());
|
||||||
if(this.options.loadTextURL) {
|
var fld;
|
||||||
text = this.options.loadingText;
|
if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) {
|
||||||
} else {
|
fld = document.createElement('input');
|
||||||
text = this.getText();
|
fld.type = 'text';
|
||||||
}
|
|
||||||
|
|
||||||
var obj = this;
|
|
||||||
|
|
||||||
if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
|
|
||||||
this.options.textarea = false;
|
|
||||||
var textField = document.createElement("input");
|
|
||||||
textField.obj = this;
|
|
||||||
textField.type = "text";
|
|
||||||
textField.name = this.options.paramName;
|
|
||||||
textField.value = text;
|
|
||||||
textField.style.backgroundColor = this.options.highlightcolor;
|
|
||||||
textField.className = 'editor_field';
|
|
||||||
var size = this.options.size || this.options.cols || 0;
|
var size = this.options.size || this.options.cols || 0;
|
||||||
if (size != 0) textField.size = size;
|
if (0 < size) fld.size = size;
|
||||||
if (this.options.submitOnBlur)
|
|
||||||
textField.onblur = this.onSubmit.bind(this);
|
|
||||||
this.editField = textField;
|
|
||||||
} else {
|
} else {
|
||||||
this.options.textarea = true;
|
fld = document.createElement('textarea');
|
||||||
var textArea = document.createElement("textarea");
|
fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows);
|
||||||
textArea.obj = this;
|
fld.cols = this.options.cols || 40;
|
||||||
textArea.name = this.options.paramName;
|
}
|
||||||
textArea.value = this.convertHTMLLineBreaks(text);
|
fld.name = this.options.paramName;
|
||||||
textArea.rows = this.options.rows;
|
fld.value = text; // No HTML breaks conversion anymore
|
||||||
textArea.cols = this.options.cols || 40;
|
fld.className = 'editor_field';
|
||||||
textArea.className = 'editor_field';
|
|
||||||
if (this.options.submitOnBlur)
|
if (this.options.submitOnBlur)
|
||||||
textArea.onblur = this.onSubmit.bind(this);
|
fld.onblur = this._boundSubmitHandler;
|
||||||
this.editField = textArea;
|
this._controls.editor = fld;
|
||||||
}
|
if (this.options.loadTextURL)
|
||||||
|
|
||||||
if(this.options.loadTextURL) {
|
|
||||||
this.loadExternalText();
|
this.loadExternalText();
|
||||||
}
|
this._form.appendChild(this._controls.editor);
|
||||||
this.form.appendChild(this.editField);
|
},
|
||||||
|
createForm: function() {
|
||||||
|
var ipe = this;
|
||||||
|
function addText(mode, condition) {
|
||||||
|
var text = ipe.options['text' + mode + 'Controls'];
|
||||||
|
if (!text || condition === false) return;
|
||||||
|
ipe._form.appendChild(document.createTextNode(text));
|
||||||
|
};
|
||||||
|
this._form = $(document.createElement('form'));
|
||||||
|
this._form.id = this.options.formId;
|
||||||
|
this._form.addClassName(this.options.formClassName);
|
||||||
|
this._form.onsubmit = this._boundSubmitHandler;
|
||||||
|
this.createEditField();
|
||||||
|
if ('textarea' == this._controls.editor.tagName.toLowerCase())
|
||||||
|
this._form.appendChild(document.createElement('br'));
|
||||||
|
if (this.options.onFormCustomization)
|
||||||
|
this.options.onFormCustomization(this, this._form);
|
||||||
|
addText('Before', this.options.okControl || this.options.cancelControl);
|
||||||
|
this.createControl('ok', this._boundSubmitHandler);
|
||||||
|
addText('Between', this.options.okControl && this.options.cancelControl);
|
||||||
|
this.createControl('cancel', this._boundCancelHandler, 'editor_cancel');
|
||||||
|
addText('After', this.options.okControl || this.options.cancelControl);
|
||||||
|
},
|
||||||
|
destroy: function() {
|
||||||
|
if (this._oldInnerHTML)
|
||||||
|
this.element.innerHTML = this._oldInnerHTML;
|
||||||
|
this.leaveEditMode();
|
||||||
|
this.unregisterListeners();
|
||||||
|
},
|
||||||
|
enterEditMode: function(e) {
|
||||||
|
if (this._saving || this._editing) return;
|
||||||
|
this._editing = true;
|
||||||
|
this.triggerCallback('onEnterEditMode');
|
||||||
|
if (this.options.externalControl)
|
||||||
|
this.options.externalControl.hide();
|
||||||
|
this.element.hide();
|
||||||
|
this.createForm();
|
||||||
|
this.element.parentNode.insertBefore(this._form, this.element);
|
||||||
|
if (!this.options.loadTextURL)
|
||||||
|
this.postProcessEditField();
|
||||||
|
if (e) Event.stop(e);
|
||||||
|
},
|
||||||
|
enterHover: function(e) {
|
||||||
|
if (this.options.hoverClassName)
|
||||||
|
this.element.addClassName(this.options.hoverClassName);
|
||||||
|
if (this._saving) return;
|
||||||
|
this.triggerCallback('onEnterHover');
|
||||||
},
|
},
|
||||||
getText: function() {
|
getText: function() {
|
||||||
return this.element.innerHTML;
|
return this.element.innerHTML;
|
||||||
},
|
},
|
||||||
loadExternalText: function() {
|
handleAJAXFailure: function(transport) {
|
||||||
Element.addClassName(this.form, this.options.loadingClassName);
|
this.triggerCallback('onFailure', transport);
|
||||||
this.editField.disabled = true;
|
if (this._oldInnerHTML) {
|
||||||
new Ajax.Request(
|
this.element.innerHTML = this._oldInnerHTML;
|
||||||
this.options.loadTextURL,
|
this._oldInnerHTML = null;
|
||||||
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();
|
|
||||||
Field.scrollFreeActivate(this.editField);
|
|
||||||
},
|
|
||||||
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() {
|
handleFormCancellation: function(e) {
|
||||||
// onLoading resets these so we need to save them away for the Ajax call
|
this.wrapUp();
|
||||||
var form = this.form;
|
if (e) Event.stop(e);
|
||||||
var value = this.editField.value;
|
},
|
||||||
|
handleFormSubmission: function(e) {
|
||||||
// do this first, sometimes the ajax call returns before we get a chance to switch on Saving...
|
var form = this._form;
|
||||||
// which means this will actually switch on Saving... *after* we've left edit mode causing Saving...
|
var value = $F(this._controls.editor);
|
||||||
// to be displayed indefinitely
|
this.prepareSubmission();
|
||||||
this.onLoading();
|
var params = this.options.callback(form, value);
|
||||||
|
params = (params ? params + '&' : '?') + 'editorId=' + this.element.id;
|
||||||
if (this.options.evalScripts) {
|
if (this.options.htmlResponse) {
|
||||||
new Ajax.Request(
|
var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions);
|
||||||
this.url, Object.extend({
|
Object.extend(options, {
|
||||||
parameters: this.options.callback(form, value),
|
parameters: params,
|
||||||
onComplete: this.onComplete.bind(this),
|
onComplete: this._boundWrapperHandler,
|
||||||
onFailure: this.onFailure.bind(this),
|
onFailure: this._boundFailureHandler
|
||||||
asynchronous:true,
|
});
|
||||||
evalScripts:true
|
new Ajax.Updater({ success: this.element }, this.url, options);
|
||||||
}, this.options.ajaxOptions));
|
|
||||||
} else {
|
} else {
|
||||||
new Ajax.Updater(
|
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
|
||||||
{ success: this.element,
|
Object.extend(options, {
|
||||||
// don't update on failure (this could be an option)
|
parameters: params,
|
||||||
failure: null },
|
onComplete: this._boundWrapperHandler,
|
||||||
this.url, Object.extend({
|
onFailure: this._boundFailureHandler
|
||||||
parameters: this.options.callback(form, value),
|
});
|
||||||
onComplete: this.onComplete.bind(this),
|
new Ajax.Request(this.url, options);
|
||||||
onFailure: this.onFailure.bind(this)
|
|
||||||
}, this.options.ajaxOptions));
|
|
||||||
}
|
}
|
||||||
// stop the event to avoid a page refresh in Safari
|
if (e) Event.stop(e);
|
||||||
if (arguments.length > 1) {
|
|
||||||
Event.stop(arguments[0]);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
},
|
||||||
onLoading: function() {
|
leaveEditMode: function() {
|
||||||
this.saving = true;
|
this.element.removeClassName(this.options.savingClassName);
|
||||||
|
this.removeForm();
|
||||||
|
this.leaveHover();
|
||||||
|
this.element.style.backgroundColor = this._originalBackground;
|
||||||
|
this.element.show();
|
||||||
|
if (this.options.externalControl)
|
||||||
|
this.options.externalControl.show();
|
||||||
|
this._saving = false;
|
||||||
|
this._editing = false;
|
||||||
|
this._oldInnerHTML = null;
|
||||||
|
this.triggerCallback('onLeaveEditMode');
|
||||||
|
},
|
||||||
|
leaveHover: function(e) {
|
||||||
|
if (this.options.hoverClassName)
|
||||||
|
this.element.removeClassName(this.options.hoverClassName);
|
||||||
|
if (this._saving) return;
|
||||||
|
this.triggerCallback('onLeaveHover');
|
||||||
|
},
|
||||||
|
loadExternalText: function() {
|
||||||
|
this._form.addClassName(this.options.loadingClassName);
|
||||||
|
this._controls.editor.disabled = true;
|
||||||
|
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
|
||||||
|
Object.extend(options, {
|
||||||
|
parameters: 'editorId=' + encodeURIComponent(this.element.id),
|
||||||
|
onComplete: Prototype.emptyFunction,
|
||||||
|
onSuccess: function(transport) {
|
||||||
|
this._form.removeClassName(this.options.loadingClassName);
|
||||||
|
var text = transport.responseText;
|
||||||
|
if (this.options.stripLoadedTextTags)
|
||||||
|
text = text.stripTags();
|
||||||
|
this._controls.editor.value = text;
|
||||||
|
this._controls.editor.disabled = false;
|
||||||
|
this.postProcessEditField();
|
||||||
|
}.bind(this),
|
||||||
|
onFailure: this._boundFailureHandler
|
||||||
|
});
|
||||||
|
new Ajax.Request(this.options.loadTextURL, options);
|
||||||
|
},
|
||||||
|
postProcessEditField: function() {
|
||||||
|
var fpc = this.options.fieldPostCreation;
|
||||||
|
if (fpc)
|
||||||
|
$(this._controls.editor)['focus' == fpc ? 'focus' : 'activate']();
|
||||||
|
},
|
||||||
|
prepareOptions: function() {
|
||||||
|
this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions);
|
||||||
|
Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks);
|
||||||
|
[this._extraDefaultOptions].flatten().compact().each(function(defs) {
|
||||||
|
Object.extend(this.options, defs);
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
prepareSubmission: function() {
|
||||||
|
this._saving = true;
|
||||||
this.removeForm();
|
this.removeForm();
|
||||||
this.leaveHover();
|
this.leaveHover();
|
||||||
this.showSaving();
|
this.showSaving();
|
||||||
},
|
},
|
||||||
showSaving: function() {
|
registerListeners: function() {
|
||||||
this.oldInnerHTML = this.element.innerHTML;
|
this._listeners = { };
|
||||||
this.element.innerHTML = this.options.savingText;
|
var listener;
|
||||||
Element.addClassName(this.element, this.options.savingClassName);
|
$H(Ajax.InPlaceEditor.Listeners).each(function(pair) {
|
||||||
this.element.style.backgroundColor = this.originalBackground;
|
listener = this[pair.value].bind(this);
|
||||||
Element.show(this.element);
|
this._listeners[pair.key] = listener;
|
||||||
|
if (!this.options.externalControlOnly)
|
||||||
|
this.element.observe(pair.key, listener);
|
||||||
|
if (this.options.externalControl)
|
||||||
|
this.options.externalControl.observe(pair.key, listener);
|
||||||
|
}.bind(this));
|
||||||
},
|
},
|
||||||
removeForm: function() {
|
removeForm: function() {
|
||||||
if(this.form) {
|
if (!this._form) return;
|
||||||
if (this.form.parentNode) Element.remove(this.form);
|
this._form.remove();
|
||||||
this.form = null;
|
this._form = null;
|
||||||
|
this._controls = { };
|
||||||
|
},
|
||||||
|
showSaving: function() {
|
||||||
|
this._oldInnerHTML = this.element.innerHTML;
|
||||||
|
this.element.innerHTML = this.options.savingText;
|
||||||
|
this.element.addClassName(this.options.savingClassName);
|
||||||
|
this.element.style.backgroundColor = this._originalBackground;
|
||||||
|
this.element.show();
|
||||||
|
},
|
||||||
|
triggerCallback: function(cbName, arg) {
|
||||||
|
if ('function' == typeof this.options[cbName]) {
|
||||||
|
this.options[cbName](this, arg);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enterHover: function() {
|
unregisterListeners: function() {
|
||||||
if (this.saving) return;
|
$H(this._listeners).each(function(pair) {
|
||||||
this.element.style.backgroundColor = this.options.highlightcolor;
|
if (!this.options.externalControlOnly)
|
||||||
if (this.effect) {
|
this.element.stopObserving(pair.key, pair.value);
|
||||||
this.effect.cancel();
|
if (this.options.externalControl)
|
||||||
}
|
this.options.externalControl.stopObserving(pair.key, pair.value);
|
||||||
Element.addClassName(this.element, this.options.hoverClassName)
|
}.bind(this));
|
||||||
},
|
},
|
||||||
leaveHover: function() {
|
wrapUp: function(transport) {
|
||||||
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.leaveEditMode();
|
||||||
this.options.onComplete.bind(this)(transport, this.element);
|
// Can't use triggerCallback due to backward compatibility: requires
|
||||||
},
|
// binding + direct element
|
||||||
onEnterEditMode: function() {},
|
this._boundComplete(transport, this.element);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Object.extend(Ajax.InPlaceEditor.prototype, {
|
||||||
|
dispose: Ajax.InPlaceEditor.prototype.destroy
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
Ajax.InPlaceCollectionEditor = Class.create();
|
Ajax.InPlaceCollectionEditor = Class.create();
|
||||||
|
Ajax.InPlaceCollectionEditor.DefaultOptions = {
|
||||||
|
loadingCollectionText: 'Loading options...'
|
||||||
|
};
|
||||||
Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype);
|
Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype);
|
||||||
Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
|
Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
|
||||||
createEditField: function() {
|
initialize: function(element, url, options) {
|
||||||
if (!this.cached_selectTag) {
|
this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions;
|
||||||
var selectTag = document.createElement("select");
|
Ajax.InPlaceEditor.prototype.initialize.call(this, element, url, options);
|
||||||
var collection = this.options.collection || [];
|
},
|
||||||
var optionTag;
|
|
||||||
collection.each(function(e,i) {
|
|
||||||
optionTag = document.createElement("option");
|
|
||||||
optionTag.value = (e instanceof Array) ? e[0] : e;
|
|
||||||
if((typeof this.options.value == 'undefined') &&
|
|
||||||
((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true;
|
|
||||||
if(this.options.value==optionTag.value) optionTag.selected = true;
|
|
||||||
optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e));
|
|
||||||
selectTag.appendChild(optionTag);
|
|
||||||
}.bind(this));
|
|
||||||
this.cached_selectTag = selectTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.editField = this.cached_selectTag;
|
createEditField: function() {
|
||||||
if(this.options.loadTextURL) this.loadExternalText();
|
var list = document.createElement('select');
|
||||||
this.form.appendChild(this.editField);
|
list.name = this.options.paramName;
|
||||||
this.options.callback = function(form, value) {
|
list.size = 1;
|
||||||
return "value=" + encodeURIComponent(value);
|
this._controls.editor = list;
|
||||||
|
this._collection = this.options.collection || [];
|
||||||
|
if (this.options.loadCollectionURL)
|
||||||
|
this.loadCollection();
|
||||||
|
else
|
||||||
|
this.checkForExternalText();
|
||||||
|
this._form.appendChild(this._controls.editor);
|
||||||
|
},
|
||||||
|
|
||||||
|
loadCollection: function() {
|
||||||
|
this._form.addClassName(this.options.loadingClassName);
|
||||||
|
this.showLoadingText(this.options.loadingCollectionText);
|
||||||
|
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
|
||||||
|
Object.extend(options, {
|
||||||
|
parameters: 'editorId=' + encodeURIComponent(this.element.id),
|
||||||
|
onComplete: Prototype.emptyFunction,
|
||||||
|
onSuccess: function(transport) {
|
||||||
|
var js = transport.responseText.strip();
|
||||||
|
if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
|
||||||
|
throw 'Server returned an invalid collection representation.';
|
||||||
|
this._collection = eval(js);
|
||||||
|
this.checkForExternalText();
|
||||||
|
}.bind(this),
|
||||||
|
onFailure: this.onFailure
|
||||||
|
});
|
||||||
|
new Ajax.Request(this.options.loadCollectionURL, options);
|
||||||
|
},
|
||||||
|
|
||||||
|
showLoadingText: function(text) {
|
||||||
|
this._controls.editor.disabled = true;
|
||||||
|
var tempOption = this._controls.editor.firstChild;
|
||||||
|
if (!tempOption) {
|
||||||
|
tempOption = document.createElement('option');
|
||||||
|
tempOption.value = '';
|
||||||
|
this._controls.editor.appendChild(tempOption);
|
||||||
|
tempOption.selected = true;
|
||||||
}
|
}
|
||||||
|
tempOption.update((text || '').stripScripts().stripTags());
|
||||||
|
},
|
||||||
|
|
||||||
|
checkForExternalText: function() {
|
||||||
|
this._text = this.getText();
|
||||||
|
if (this.options.loadTextURL)
|
||||||
|
this.loadExternalText();
|
||||||
|
else
|
||||||
|
this.buildOptionList();
|
||||||
|
},
|
||||||
|
|
||||||
|
loadExternalText: function() {
|
||||||
|
this.showLoadingText(this.options.loadingText);
|
||||||
|
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
|
||||||
|
Object.extend(options, {
|
||||||
|
parameters: 'editorId=' + encodeURIComponent(this.element.id),
|
||||||
|
onComplete: Prototype.emptyFunction,
|
||||||
|
onSuccess: function(transport) {
|
||||||
|
this._text = transport.responseText.strip();
|
||||||
|
this.buildOptionList();
|
||||||
|
}.bind(this),
|
||||||
|
onFailure: this.onFailure
|
||||||
|
});
|
||||||
|
new Ajax.Request(this.options.loadTextURL, options);
|
||||||
|
},
|
||||||
|
|
||||||
|
buildOptionList: function() {
|
||||||
|
this._form.removeClassName(this.options.loadingClassName);
|
||||||
|
this._collection = this._collection.map(function(entry) {
|
||||||
|
return 2 === entry.length ? entry : [entry, entry].flatten();
|
||||||
|
});
|
||||||
|
var marker = ('value' in this.options) ? this.options.value : this._text;
|
||||||
|
var textFound = this._collection.any(function(entry) {
|
||||||
|
return entry[0] == marker;
|
||||||
|
}.bind(this));
|
||||||
|
this._controls.editor.update('');
|
||||||
|
var option;
|
||||||
|
this._collection.each(function(entry, index) {
|
||||||
|
option = document.createElement('option');
|
||||||
|
option.value = entry[0];
|
||||||
|
option.selected = textFound ? entry[0] == marker : 0 == index;
|
||||||
|
option.appendChild(document.createTextNode(entry[1]));
|
||||||
|
this._controls.editor.appendChild(option);
|
||||||
|
}.bind(this));
|
||||||
|
this._controls.editor.disabled = false;
|
||||||
|
Field.scrollFreeActivate(this._controls.editor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! ****
|
||||||
|
//**** This only exists for a while, in order to let ****
|
||||||
|
//**** users adapt to the new API. Read up on the new ****
|
||||||
|
//**** API and convert your code to it ASAP! ****
|
||||||
|
|
||||||
|
Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) {
|
||||||
|
if (!options) return;
|
||||||
|
function fallback(name, expr) {
|
||||||
|
if (name in options || expr === undefined) return;
|
||||||
|
options[name] = expr;
|
||||||
|
};
|
||||||
|
fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' :
|
||||||
|
options.cancelLink == options.cancelButton == false ? false : undefined)));
|
||||||
|
fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' :
|
||||||
|
options.okLink == options.okButton == false ? false : undefined)));
|
||||||
|
fallback('highlightColor', options.highlightcolor);
|
||||||
|
fallback('highlightEndColor', options.highlightendcolor);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Delayed observer, like Form.Element.Observer,
|
// Delayed observer, like Form.Element.Observer,
|
||||||
// but waits for delay after last key input
|
// but waits for delay after last key input
|
||||||
// Ideal for live-search fields
|
// Ideal for live-search fields
|
||||||
|
|||||||
42
htdocs/includes/scriptaculous/src/dragdrop.js
vendored
42
htdocs/includes/scriptaculous/src/dragdrop.js
vendored
@ -1,4 +1,4 @@
|
|||||||
// script.aculo.us dragdrop.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
|
// script.aculo.us dragdrop.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
|
||||||
|
|
||||||
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
|
// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
|
||||||
@ -6,7 +6,7 @@
|
|||||||
// script.aculo.us is freely distributable under the terms of an MIT-style license.
|
// script.aculo.us is freely distributable under the terms of an MIT-style license.
|
||||||
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
||||||
|
|
||||||
if(typeof Effect == 'undefined')
|
if(Object.isUndefined(Effect))
|
||||||
throw("dragdrop.js requires including script.aculo.us' effects.js library");
|
throw("dragdrop.js requires including script.aculo.us' effects.js library");
|
||||||
|
|
||||||
var Droppables = {
|
var Droppables = {
|
||||||
@ -28,8 +28,7 @@ var Droppables = {
|
|||||||
if(options.containment) {
|
if(options.containment) {
|
||||||
options._containers = [];
|
options._containers = [];
|
||||||
var containment = options.containment;
|
var containment = options.containment;
|
||||||
if((typeof containment == 'object') &&
|
if(Object.isArray(containment)) {
|
||||||
(containment.constructor == Array)) {
|
|
||||||
containment.each( function(c) { options._containers.push($(c)) });
|
containment.each( function(c) { options._containers.push($(c)) });
|
||||||
} else {
|
} else {
|
||||||
options._containers.push($(containment));
|
options._containers.push($(containment));
|
||||||
@ -89,21 +88,23 @@ var Droppables = {
|
|||||||
|
|
||||||
show: function(point, element) {
|
show: function(point, element) {
|
||||||
if(!this.drops.length) return;
|
if(!this.drops.length) return;
|
||||||
var affected = [];
|
var drop, affected = [];
|
||||||
|
|
||||||
if(this.last_active) this.deactivate(this.last_active);
|
|
||||||
this.drops.each( function(drop) {
|
this.drops.each( function(drop) {
|
||||||
if(Droppables.isAffected(point, element, drop))
|
if(Droppables.isAffected(point, element, drop))
|
||||||
affected.push(drop);
|
affected.push(drop);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(affected.length>0) {
|
if(affected.length>0)
|
||||||
drop = Droppables.findDeepestChild(affected);
|
drop = Droppables.findDeepestChild(affected);
|
||||||
|
|
||||||
|
if(this.last_active && this.last_active != drop) this.deactivate(this.last_active);
|
||||||
|
if (drop) {
|
||||||
Position.within(drop.element, point[0], point[1]);
|
Position.within(drop.element, point[0], point[1]);
|
||||||
if(drop.onHover)
|
if(drop.onHover)
|
||||||
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
|
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
|
||||||
|
|
||||||
Droppables.activate(drop);
|
if (drop != this.last_active) Droppables.activate(drop);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -237,7 +238,7 @@ Draggable.prototype = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
endeffect: function(element) {
|
endeffect: function(element) {
|
||||||
var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0;
|
var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
|
||||||
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
|
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
|
||||||
queue: {scope:'_draggable', position:'end'},
|
queue: {scope:'_draggable', position:'end'},
|
||||||
afterFinish: function(){
|
afterFinish: function(){
|
||||||
@ -255,7 +256,7 @@ Draggable.prototype = {
|
|||||||
delay: 0
|
delay: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!arguments[1] || typeof arguments[1].endeffect == 'undefined')
|
if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
|
||||||
Object.extend(defaults, {
|
Object.extend(defaults, {
|
||||||
starteffect: function(element) {
|
starteffect: function(element) {
|
||||||
element._opacity = Element.getOpacity(element);
|
element._opacity = Element.getOpacity(element);
|
||||||
@ -268,7 +269,7 @@ Draggable.prototype = {
|
|||||||
|
|
||||||
this.element = $(element);
|
this.element = $(element);
|
||||||
|
|
||||||
if(options.handle && (typeof options.handle == 'string'))
|
if(options.handle && Object.isString(options.handle))
|
||||||
this.handle = this.element.down('.'+options.handle, 0);
|
this.handle = this.element.down('.'+options.handle, 0);
|
||||||
|
|
||||||
if(!this.handle) this.handle = $(options.handle);
|
if(!this.handle) this.handle = $(options.handle);
|
||||||
@ -281,7 +282,6 @@ Draggable.prototype = {
|
|||||||
|
|
||||||
Element.makePositioned(this.element); // fix IE
|
Element.makePositioned(this.element); // fix IE
|
||||||
|
|
||||||
this.delta = this.currentDelta();
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.dragging = false;
|
this.dragging = false;
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ Draggable.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
initDrag: function(event) {
|
initDrag: function(event) {
|
||||||
if(typeof Draggable._dragging[this.element] != 'undefined' &&
|
if(!Object.isUndefined(Draggable._dragging[this.element]) &&
|
||||||
Draggable._dragging[this.element]) return;
|
Draggable._dragging[this.element]) return;
|
||||||
if(Event.isLeftClick(event)) {
|
if(Event.isLeftClick(event)) {
|
||||||
// abort on form elements, fixes a Firefox issue
|
// abort on form elements, fixes a Firefox issue
|
||||||
@ -326,6 +326,8 @@ Draggable.prototype = {
|
|||||||
|
|
||||||
startDrag: function(event) {
|
startDrag: function(event) {
|
||||||
this.dragging = true;
|
this.dragging = true;
|
||||||
|
if(!this.delta)
|
||||||
|
this.delta = this.currentDelta();
|
||||||
|
|
||||||
if(this.options.zindex) {
|
if(this.options.zindex) {
|
||||||
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
|
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
|
||||||
@ -334,6 +336,8 @@ Draggable.prototype = {
|
|||||||
|
|
||||||
if(this.options.ghosting) {
|
if(this.options.ghosting) {
|
||||||
this._clone = this.element.cloneNode(true);
|
this._clone = this.element.cloneNode(true);
|
||||||
|
this.element._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
|
||||||
|
if (!this.element._originallyAbsolute)
|
||||||
Position.absolutize(this.element);
|
Position.absolutize(this.element);
|
||||||
this.element.parentNode.insertBefore(this._clone, this.element);
|
this.element.parentNode.insertBefore(this._clone, this.element);
|
||||||
}
|
}
|
||||||
@ -404,7 +408,9 @@ Draggable.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(this.options.ghosting) {
|
if(this.options.ghosting) {
|
||||||
|
if (!this.element._originallyAbsolute)
|
||||||
Position.relativize(this.element);
|
Position.relativize(this.element);
|
||||||
|
delete this.element._originallyAbsolute;
|
||||||
Element.remove(this._clone);
|
Element.remove(this._clone);
|
||||||
this._clone = null;
|
this._clone = null;
|
||||||
}
|
}
|
||||||
@ -418,7 +424,7 @@ Draggable.prototype = {
|
|||||||
Draggables.notify('onEnd', this, event);
|
Draggables.notify('onEnd', this, event);
|
||||||
|
|
||||||
var revert = this.options.revert;
|
var revert = this.options.revert;
|
||||||
if(revert && typeof revert == 'function') revert = revert(this.element);
|
if(revert && Object.isFunction(revert)) revert = revert(this.element);
|
||||||
|
|
||||||
var d = this.currentDelta();
|
var d = this.currentDelta();
|
||||||
if(revert && this.options.reverteffect) {
|
if(revert && this.options.reverteffect) {
|
||||||
@ -472,15 +478,15 @@ Draggable.prototype = {
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
if(this.options.snap) {
|
if(this.options.snap) {
|
||||||
if(typeof this.options.snap == 'function') {
|
if(Object.isFunction(this.options.snap)) {
|
||||||
p = this.options.snap(p[0],p[1],this);
|
p = this.options.snap(p[0],p[1],this);
|
||||||
} else {
|
} else {
|
||||||
if(this.options.snap instanceof Array) {
|
if(Object.isArray(this.options.snap)) {
|
||||||
p = p.map( function(v, i) {
|
p = p.map( function(v, i) {
|
||||||
return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this))
|
return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this))
|
||||||
} else {
|
} else {
|
||||||
p = p.map( function(v) {
|
p = p.map( function(v) {
|
||||||
return Math.round(v/this.options.snap)*this.options.snap }.bind(this))
|
return (v/this.options.snap).round()*this.options.snap }.bind(this))
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|||||||
395
htdocs/includes/scriptaculous/src/effects.js
vendored
395
htdocs/includes/scriptaculous/src/effects.js
vendored
@ -1,4 +1,4 @@
|
|||||||
// script.aculo.us effects.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
|
// script.aculo.us effects.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
|
||||||
|
|
||||||
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
// Contributors:
|
// Contributors:
|
||||||
@ -23,7 +23,7 @@ String.prototype.parseColor = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (color.length==7 ? color : (arguments[0] || this));
|
return (color.length==7 ? color : (arguments[0] || this));
|
||||||
}
|
};
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ Element.collectTextNodes = function(element) {
|
|||||||
return (node.nodeType==3 ? node.nodeValue :
|
return (node.nodeType==3 ? node.nodeValue :
|
||||||
(node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
|
(node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
|
||||||
}).flatten().join('');
|
}).flatten().join('');
|
||||||
}
|
};
|
||||||
|
|
||||||
Element.collectTextNodesIgnoreClass = function(element, className) {
|
Element.collectTextNodesIgnoreClass = function(element, className) {
|
||||||
return $A($(element).childNodes).collect( function(node) {
|
return $A($(element).childNodes).collect( function(node) {
|
||||||
@ -40,18 +40,18 @@ Element.collectTextNodesIgnoreClass = function(element, className) {
|
|||||||
((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
|
((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
|
||||||
Element.collectTextNodesIgnoreClass(node, className) : ''));
|
Element.collectTextNodesIgnoreClass(node, className) : ''));
|
||||||
}).flatten().join('');
|
}).flatten().join('');
|
||||||
}
|
};
|
||||||
|
|
||||||
Element.setContentZoom = function(element, percent) {
|
Element.setContentZoom = function(element, percent) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
element.setStyle({fontSize: (percent/100) + 'em'});
|
element.setStyle({fontSize: (percent/100) + 'em'});
|
||||||
if (Prototype.Browser.WebKit) window.scrollBy(0,0);
|
if (Prototype.Browser.WebKit) window.scrollBy(0,0);
|
||||||
return element;
|
return element;
|
||||||
}
|
};
|
||||||
|
|
||||||
Element.getInlineOpacity = function(element){
|
Element.getInlineOpacity = function(element){
|
||||||
return $(element).style.opacity || '';
|
return $(element).style.opacity || '';
|
||||||
}
|
};
|
||||||
|
|
||||||
Element.forceRerendering = function(element) {
|
Element.forceRerendering = function(element) {
|
||||||
try {
|
try {
|
||||||
@ -64,22 +64,54 @@ Element.forceRerendering = function(element) {
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
Array.prototype.call = function() {
|
|
||||||
var args = arguments;
|
|
||||||
this.each(function(f){ f.apply(this, args) });
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
var Effect = {
|
var Effect = {
|
||||||
_elementDoesNotExistError: {
|
_elementDoesNotExistError: {
|
||||||
name: 'ElementDoesNotExistError',
|
name: 'ElementDoesNotExistError',
|
||||||
message: 'The specified DOM element does not exist, but is required for this effect to operate'
|
message: 'The specified DOM element does not exist, but is required for this effect to operate'
|
||||||
},
|
},
|
||||||
|
Transitions: {
|
||||||
|
linear: Prototype.K,
|
||||||
|
sinoidal: function(pos) {
|
||||||
|
return (-Math.cos(pos*Math.PI)/2) + 0.5;
|
||||||
|
},
|
||||||
|
reverse: function(pos) {
|
||||||
|
return 1-pos;
|
||||||
|
},
|
||||||
|
flicker: function(pos) {
|
||||||
|
var pos = ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
|
||||||
|
return pos > 1 ? 1 : pos;
|
||||||
|
},
|
||||||
|
wobble: function(pos) {
|
||||||
|
return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
|
||||||
|
},
|
||||||
|
pulse: function(pos, pulses) {
|
||||||
|
pulses = pulses || 5;
|
||||||
|
return (
|
||||||
|
((pos % (1/pulses)) * pulses).round() == 0 ?
|
||||||
|
((pos * pulses * 2) - (pos * pulses * 2).floor()) :
|
||||||
|
1 - ((pos * pulses * 2) - (pos * pulses * 2).floor())
|
||||||
|
);
|
||||||
|
},
|
||||||
|
spring: function(pos) {
|
||||||
|
return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6));
|
||||||
|
},
|
||||||
|
none: function(pos) {
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
full: function(pos) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
DefaultOptions: {
|
||||||
|
duration: 1.0, // seconds
|
||||||
|
fps: 100, // 100= assume 66fps max.
|
||||||
|
sync: false, // true for combining
|
||||||
|
from: 0.0,
|
||||||
|
to: 1.0,
|
||||||
|
delay: 0.0,
|
||||||
|
queue: 'parallel'
|
||||||
|
},
|
||||||
tagifyText: function(element) {
|
tagifyText: function(element) {
|
||||||
if(typeof Builder == 'undefined')
|
|
||||||
throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
|
|
||||||
|
|
||||||
var tagifyStyle = 'position:relative';
|
var tagifyStyle = 'position:relative';
|
||||||
if (Prototype.Browser.IE) tagifyStyle += ';zoom:1';
|
if (Prototype.Browser.IE) tagifyStyle += ';zoom:1';
|
||||||
|
|
||||||
@ -88,7 +120,7 @@ var Effect = {
|
|||||||
if (child.nodeType==3) {
|
if (child.nodeType==3) {
|
||||||
child.nodeValue.toArray().each( function(character) {
|
child.nodeValue.toArray().each( function(character) {
|
||||||
element.insertBefore(
|
element.insertBefore(
|
||||||
Builder.node('span',{style: tagifyStyle},
|
new Element('span', {style: tagifyStyle}).update(
|
||||||
character == ' ' ? String.fromCharCode(160) : character),
|
character == ' ' ? String.fromCharCode(160) : character),
|
||||||
child);
|
child);
|
||||||
});
|
});
|
||||||
@ -99,7 +131,7 @@ var Effect = {
|
|||||||
multiple: function(element, effect) {
|
multiple: function(element, effect) {
|
||||||
var elements;
|
var elements;
|
||||||
if (((typeof element == 'object') ||
|
if (((typeof element == 'object') ||
|
||||||
(typeof element == 'function')) &&
|
Object.isFunction(element)) &&
|
||||||
(element.length))
|
(element.length))
|
||||||
elements = element;
|
elements = element;
|
||||||
else
|
else
|
||||||
@ -131,45 +163,11 @@ var Effect = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var Effect2 = Effect; // deprecated
|
Effect.DefaultOptions.transition = Effect.Transitions.sinoidal;
|
||||||
|
|
||||||
/* ------------- transitions ------------- */
|
|
||||||
|
|
||||||
Effect.Transitions = {
|
|
||||||
linear: Prototype.K,
|
|
||||||
sinoidal: function(pos) {
|
|
||||||
return (-Math.cos(pos*Math.PI)/2) + 0.5;
|
|
||||||
},
|
|
||||||
reverse: function(pos) {
|
|
||||||
return 1-pos;
|
|
||||||
},
|
|
||||||
flicker: function(pos) {
|
|
||||||
var pos = ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
|
|
||||||
return (pos > 1 ? 1 : pos);
|
|
||||||
},
|
|
||||||
wobble: function(pos) {
|
|
||||||
return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
|
|
||||||
},
|
|
||||||
pulse: function(pos, pulses) {
|
|
||||||
pulses = pulses || 5;
|
|
||||||
return (
|
|
||||||
Math.round((pos % (1/pulses)) * pulses) == 0 ?
|
|
||||||
((pos * pulses * 2) - Math.floor(pos * pulses * 2)) :
|
|
||||||
1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2))
|
|
||||||
);
|
|
||||||
},
|
|
||||||
none: function(pos) {
|
|
||||||
return 0;
|
|
||||||
},
|
|
||||||
full: function(pos) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ------------- core effects ------------- */
|
/* ------------- core effects ------------- */
|
||||||
|
|
||||||
Effect.ScopedQueue = Class.create();
|
Effect.ScopedQueue = Class.create(Enumerable, {
|
||||||
Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.effects = [];
|
this.effects = [];
|
||||||
this.interval = null;
|
this.interval = null;
|
||||||
@ -180,7 +178,7 @@ Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
|
|||||||
add: function(effect) {
|
add: function(effect) {
|
||||||
var timestamp = new Date().getTime();
|
var timestamp = new Date().getTime();
|
||||||
|
|
||||||
var position = (typeof effect.options.queue == 'string') ?
|
var position = Object.isString(effect.options.queue) ?
|
||||||
effect.options.queue : effect.options.queue.position;
|
effect.options.queue : effect.options.queue.position;
|
||||||
|
|
||||||
switch(position) {
|
switch(position) {
|
||||||
@ -226,28 +224,17 @@ Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
|
|||||||
Effect.Queues = {
|
Effect.Queues = {
|
||||||
instances: $H(),
|
instances: $H(),
|
||||||
get: function(queueName) {
|
get: function(queueName) {
|
||||||
if(typeof queueName != 'string') return queueName;
|
if (!Object.isString(queueName)) return queueName;
|
||||||
|
|
||||||
if (!this.instances[queueName])
|
if (!this.instances[queueName])
|
||||||
this.instances[queueName] = new Effect.ScopedQueue();
|
this.instances[queueName] = new Effect.ScopedQueue();
|
||||||
|
|
||||||
return this.instances[queueName];
|
return this.instances[queueName];
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
Effect.Queue = Effect.Queues.get('global');
|
Effect.Queue = Effect.Queues.get('global');
|
||||||
|
|
||||||
Effect.DefaultOptions = {
|
Effect.Base = Class.create();
|
||||||
transition: Effect.Transitions.sinoidal,
|
|
||||||
duration: 1.0, // seconds
|
|
||||||
fps: 100, // 100= assume 66fps max.
|
|
||||||
sync: false, // true for combining
|
|
||||||
from: 0.0,
|
|
||||||
to: 1.0,
|
|
||||||
delay: 0.0,
|
|
||||||
queue: 'parallel'
|
|
||||||
}
|
|
||||||
|
|
||||||
Effect.Base = function() {};
|
|
||||||
Effect.Base.prototype = {
|
Effect.Base.prototype = {
|
||||||
position: null,
|
position: null,
|
||||||
start: function(options) {
|
start: function(options) {
|
||||||
@ -257,7 +244,7 @@ Effect.Base.prototype = {
|
|||||||
(options[eventName] ? 'this.options.'+eventName+'(this);' : '')
|
(options[eventName] ? 'this.options.'+eventName+'(this);' : '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(options.transition === false) options.transition = Effect.Transitions.linear;
|
if (options && options.transition === false) options.transition = Effect.Transitions.linear;
|
||||||
this.options = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { });
|
this.options = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { });
|
||||||
this.currentFrame = 0;
|
this.currentFrame = 0;
|
||||||
this.state = 'idle';
|
this.state = 'idle';
|
||||||
@ -269,20 +256,20 @@ Effect.Base.prototype = {
|
|||||||
|
|
||||||
eval('this.render = function(pos){ '+
|
eval('this.render = function(pos){ '+
|
||||||
'if (this.state=="idle"){this.state="running";'+
|
'if (this.state=="idle"){this.state="running";'+
|
||||||
codeForEvent(options,'beforeSetup')+
|
codeForEvent(this.options,'beforeSetup')+
|
||||||
(this.setup ? 'this.setup();':'')+
|
(this.setup ? 'this.setup();':'')+
|
||||||
codeForEvent(options,'afterSetup')+
|
codeForEvent(this.options,'afterSetup')+
|
||||||
'};if (this.state=="running"){'+
|
'};if (this.state=="running"){'+
|
||||||
'pos=this.options.transition(pos)*'+this.fromToDelta+'+'+this.options.from+';'+
|
'pos=this.options.transition(pos)*'+this.fromToDelta+'+'+this.options.from+';'+
|
||||||
'this.position=pos;'+
|
'this.position=pos;'+
|
||||||
codeForEvent(options,'beforeUpdate')+
|
codeForEvent(this.options,'beforeUpdate')+
|
||||||
(this.update ? 'this.update(pos);':'')+
|
(this.update ? 'this.update(pos);':'')+
|
||||||
codeForEvent(options,'afterUpdate')+
|
codeForEvent(this.options,'afterUpdate')+
|
||||||
'}}');
|
'}}');
|
||||||
|
|
||||||
this.event('beforeStart');
|
this.event('beforeStart');
|
||||||
if (!this.options.sync)
|
if (!this.options.sync)
|
||||||
Effect.Queues.get(typeof this.options.queue == 'string' ?
|
Effect.Queues.get(Object.isString(this.options.queue) ?
|
||||||
'global' : this.options.queue.scope).add(this);
|
'global' : this.options.queue.scope).add(this);
|
||||||
},
|
},
|
||||||
loop: function(timePos) {
|
loop: function(timePos) {
|
||||||
@ -296,7 +283,7 @@ Effect.Base.prototype = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var pos = (timePos - this.startOn) / this.totalTime,
|
var pos = (timePos - this.startOn) / this.totalTime,
|
||||||
frame = Math.round(pos * this.totalFrames);
|
frame = (pos * this.totalFrames).round();
|
||||||
if (frame > this.currentFrame) {
|
if (frame > this.currentFrame) {
|
||||||
this.render(pos);
|
this.render(pos);
|
||||||
this.currentFrame = frame;
|
this.currentFrame = frame;
|
||||||
@ -305,7 +292,7 @@ Effect.Base.prototype = {
|
|||||||
},
|
},
|
||||||
cancel: function() {
|
cancel: function() {
|
||||||
if (!this.options.sync)
|
if (!this.options.sync)
|
||||||
Effect.Queues.get(typeof this.options.queue == 'string' ?
|
Effect.Queues.get(Object.isString(this.options.queue) ?
|
||||||
'global' : this.options.queue.scope).remove(this);
|
'global' : this.options.queue.scope).remove(this);
|
||||||
this.state = 'finished';
|
this.state = 'finished';
|
||||||
},
|
},
|
||||||
@ -316,13 +303,12 @@ Effect.Base.prototype = {
|
|||||||
inspect: function() {
|
inspect: function() {
|
||||||
var data = $H();
|
var data = $H();
|
||||||
for(property in this)
|
for(property in this)
|
||||||
if(typeof this[property] != 'function') data[property] = this[property];
|
if (!Object.isFunction(this[property])) data[property] = this[property];
|
||||||
return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>';
|
return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>';
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.Parallel = Class.create();
|
Effect.Parallel = Class.create(Effect.Base, {
|
||||||
Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
|
|
||||||
initialize: function(effects) {
|
initialize: function(effects) {
|
||||||
this.effects = effects || [];
|
this.effects = effects || [];
|
||||||
this.start(arguments[1]);
|
this.start(arguments[1]);
|
||||||
@ -341,19 +327,29 @@ Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Effect.Event = Class.create();
|
Effect.Tween = Class.create(Effect.Base, {
|
||||||
Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), {
|
initialize: function(object, from, to) {
|
||||||
|
object = Object.isString(object) ? $(object) : object;
|
||||||
|
var args = $A(arguments), method = args.last(),
|
||||||
|
options = args.length == 5 ? args[3] : null;
|
||||||
|
this.method = Object.isFunction(method) ? method.bind(object) :
|
||||||
|
Object.isFunction(object[method]) ? object[method].bind(object) :
|
||||||
|
function(value) { object[method] = value };
|
||||||
|
this.start(Object.extend({ from: from, to: to }, options || { }));
|
||||||
|
},
|
||||||
|
update: function(position) {
|
||||||
|
this.method(position);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.Event = Class.create(Effect.Base, {
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
var options = Object.extend({
|
this.start(Object.extend({ duration: 0 }, arguments[0] || { }));
|
||||||
duration: 0
|
|
||||||
}, arguments[0] || {});
|
|
||||||
this.start(options);
|
|
||||||
},
|
},
|
||||||
update: Prototype.emptyFunction
|
update: Prototype.emptyFunction
|
||||||
});
|
});
|
||||||
|
|
||||||
Effect.Opacity = Class.create();
|
Effect.Opacity = Class.create(Effect.Base, {
|
||||||
Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
|
|
||||||
initialize: function(element) {
|
initialize: function(element) {
|
||||||
this.element = $(element);
|
this.element = $(element);
|
||||||
if (!this.element) throw(Effect._elementDoesNotExistError);
|
if (!this.element) throw(Effect._elementDoesNotExistError);
|
||||||
@ -371,8 +367,7 @@ Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Effect.Move = Class.create();
|
Effect.Move = Class.create(Effect.Base, {
|
||||||
Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
|
|
||||||
initialize: function(element) {
|
initialize: function(element) {
|
||||||
this.element = $(element);
|
this.element = $(element);
|
||||||
if (!this.element) throw(Effect._elementDoesNotExistError);
|
if (!this.element) throw(Effect._elementDoesNotExistError);
|
||||||
@ -384,23 +379,18 @@ Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
|
|||||||
this.start(options);
|
this.start(options);
|
||||||
},
|
},
|
||||||
setup: function() {
|
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)
|
|
||||||
this.element.makePositioned();
|
this.element.makePositioned();
|
||||||
this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
|
this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
|
||||||
this.originalTop = parseFloat(this.element.getStyle('top') || '0');
|
this.originalTop = parseFloat(this.element.getStyle('top') || '0');
|
||||||
if (this.options.mode == 'absolute') {
|
if (this.options.mode == 'absolute') {
|
||||||
// absolute movement, so we need to calc deltaX and deltaY
|
|
||||||
this.options.x = this.options.x - this.originalLeft;
|
this.options.x = this.options.x - this.originalLeft;
|
||||||
this.options.y = this.options.y - this.originalTop;
|
this.options.y = this.options.y - this.originalTop;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update: function(position) {
|
update: function(position) {
|
||||||
this.element.setStyle({
|
this.element.setStyle({
|
||||||
left: Math.round(this.options.x * position + this.originalLeft) + 'px',
|
left: (this.options.x * position + this.originalLeft).round() + 'px',
|
||||||
top: Math.round(this.options.y * position + this.originalTop) + 'px'
|
top: (this.options.y * position + this.originalTop).round() + 'px'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -411,8 +401,7 @@ Effect.MoveBy = function(element, toTop, toLeft) {
|
|||||||
Object.extend({ x: toLeft, y: toTop }, arguments[3] || { }));
|
Object.extend({ x: toLeft, y: toTop }, arguments[3] || { }));
|
||||||
};
|
};
|
||||||
|
|
||||||
Effect.Scale = Class.create();
|
Effect.Scale = Class.create(Effect.Base, {
|
||||||
Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
|
|
||||||
initialize: function(element, percent) {
|
initialize: function(element, percent) {
|
||||||
this.element = $(element);
|
this.element = $(element);
|
||||||
if (!this.element) throw(Effect._elementDoesNotExistError);
|
if (!this.element) throw(Effect._elementDoesNotExistError);
|
||||||
@ -469,8 +458,8 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
|
|||||||
},
|
},
|
||||||
setDimensions: function(height, width) {
|
setDimensions: function(height, width) {
|
||||||
var d = { };
|
var d = { };
|
||||||
if(this.options.scaleX) d.width = Math.round(width) + 'px';
|
if (this.options.scaleX) d.width = width.round() + 'px';
|
||||||
if(this.options.scaleY) d.height = Math.round(height) + 'px';
|
if (this.options.scaleY) d.height = height.round() + 'px';
|
||||||
if (this.options.scaleFromCenter) {
|
if (this.options.scaleFromCenter) {
|
||||||
var topd = (height - this.dims[0])/2;
|
var topd = (height - this.dims[0])/2;
|
||||||
var leftd = (width - this.dims[1])/2;
|
var leftd = (width - this.dims[1])/2;
|
||||||
@ -486,8 +475,7 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Effect.Highlight = Class.create();
|
Effect.Highlight = Class.create(Effect.Base, {
|
||||||
Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
|
|
||||||
initialize: function(element) {
|
initialize: function(element) {
|
||||||
this.element = $(element);
|
this.element = $(element);
|
||||||
if (!this.element) throw(Effect._elementDoesNotExistError);
|
if (!this.element) throw(Effect._elementDoesNotExistError);
|
||||||
@ -513,7 +501,7 @@ Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype),
|
|||||||
},
|
},
|
||||||
update: function(position) {
|
update: function(position) {
|
||||||
this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
|
this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
|
||||||
return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
|
return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) });
|
||||||
},
|
},
|
||||||
finish: function() {
|
finish: function() {
|
||||||
this.element.setStyle(Object.extend(this.oldStyle, {
|
this.element.setStyle(Object.extend(this.oldStyle, {
|
||||||
@ -522,30 +510,21 @@ Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype),
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Effect.ScrollTo = Class.create();
|
Effect.ScrollTo = function(element) {
|
||||||
Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
|
var options = arguments[1] || { },
|
||||||
initialize: function(element) {
|
scrollOffsets = document.viewport.getScrollOffsets(),
|
||||||
this.element = $(element);
|
elementOffsets = $(element).cumulativeOffset(),
|
||||||
this.start(arguments[1] || {});
|
max = (window.height || document.body.scrollHeight) - document.viewport.getHeight();
|
||||||
},
|
|
||||||
setup: function() {
|
if (options.offset) elementOffsets[1] += options.offset;
|
||||||
Position.prepare();
|
|
||||||
var offsets = Position.cumulativeOffset(this.element);
|
return new Effect.Tween(null,
|
||||||
if(this.options.offset) offsets[1] += this.options.offset;
|
scrollOffsets.top,
|
||||||
var max = window.innerHeight ?
|
elementOffsets[1] > max ? max : elementOffsets[1],
|
||||||
window.height - window.innerHeight :
|
options,
|
||||||
document.body.scrollHeight -
|
function(p){ scrollTo(scrollOffsets.left, p.round()) }
|
||||||
(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 ------------- */
|
/* ------------- combination effects ------------- */
|
||||||
|
|
||||||
@ -558,9 +537,10 @@ Effect.Fade = function(element) {
|
|||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
if (effect.options.to!=0) return;
|
if (effect.options.to!=0) return;
|
||||||
effect.element.hide().setStyle({opacity: oldOpacity});
|
effect.element.hide().setStyle({opacity: oldOpacity});
|
||||||
}}, arguments[1] || {});
|
|
||||||
return new Effect.Opacity(element,options);
|
|
||||||
}
|
}
|
||||||
|
}, arguments[1] || { });
|
||||||
|
return new Effect.Opacity(element,options);
|
||||||
|
};
|
||||||
|
|
||||||
Effect.Appear = function(element) {
|
Effect.Appear = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
@ -575,7 +555,7 @@ Effect.Appear = function(element) {
|
|||||||
effect.element.setOpacity(effect.options.from).show();
|
effect.element.setOpacity(effect.options.from).show();
|
||||||
}}, arguments[1] || { });
|
}}, arguments[1] || { });
|
||||||
return new Effect.Opacity(element,options);
|
return new Effect.Opacity(element,options);
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.Puff = function(element) {
|
Effect.Puff = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
@ -599,7 +579,7 @@ Effect.Puff = function(element) {
|
|||||||
effect.effects[0].element.hide().setStyle(oldStyle); }
|
effect.effects[0].element.hide().setStyle(oldStyle); }
|
||||||
}, arguments[1] || { })
|
}, arguments[1] || { })
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.BlindUp = function(element) {
|
Effect.BlindUp = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
@ -613,7 +593,7 @@ Effect.BlindUp = function(element) {
|
|||||||
}
|
}
|
||||||
}, arguments[1] || { })
|
}, arguments[1] || { })
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.BlindDown = function(element) {
|
Effect.BlindDown = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
@ -631,7 +611,7 @@ Effect.BlindDown = function(element) {
|
|||||||
effect.element.undoClipping();
|
effect.element.undoClipping();
|
||||||
}
|
}
|
||||||
}, arguments[1] || { }));
|
}, arguments[1] || { }));
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.SwitchOff = function(element) {
|
Effect.SwitchOff = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
@ -653,7 +633,7 @@ Effect.SwitchOff = function(element) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, arguments[1] || { }));
|
}, arguments[1] || { }));
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.DropOut = function(element) {
|
Effect.DropOut = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
@ -673,7 +653,7 @@ Effect.DropOut = function(element) {
|
|||||||
effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
|
effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
|
||||||
}
|
}
|
||||||
}, arguments[1] || { }));
|
}, arguments[1] || { }));
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.Shake = function(element) {
|
Effect.Shake = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
@ -694,7 +674,7 @@ Effect.Shake = function(element) {
|
|||||||
{ x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
|
{ x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
|
||||||
effect.element.undoPositioned().setStyle(oldStyle);
|
effect.element.undoPositioned().setStyle(oldStyle);
|
||||||
}}) }}) }}) }}) }}) }});
|
}}) }}) }}) }}) }}) }});
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.SlideDown = function(element) {
|
Effect.SlideDown = function(element) {
|
||||||
element = $(element).cleanWhitespace();
|
element = $(element).cleanWhitespace();
|
||||||
@ -722,18 +702,20 @@ Effect.SlideDown = function(element) {
|
|||||||
effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
|
effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
|
||||||
}, arguments[1] || { })
|
}, arguments[1] || { })
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.SlideUp = function(element) {
|
Effect.SlideUp = function(element) {
|
||||||
element = $(element).cleanWhitespace();
|
element = $(element).cleanWhitespace();
|
||||||
var oldInnerBottom = element.down().getStyle('bottom');
|
var oldInnerBottom = element.down().getStyle('bottom');
|
||||||
|
var elementDimensions = element.getDimensions();
|
||||||
return new Effect.Scale(element, window.opera ? 0 : 1,
|
return new Effect.Scale(element, window.opera ? 0 : 1,
|
||||||
Object.extend({ scaleContent: false,
|
Object.extend({ scaleContent: false,
|
||||||
scaleX: false,
|
scaleX: false,
|
||||||
scaleMode: 'box',
|
scaleMode: 'box',
|
||||||
scaleFrom: 100,
|
scaleFrom: 100,
|
||||||
|
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
|
||||||
restoreAfterFinish: true,
|
restoreAfterFinish: true,
|
||||||
beforeStartInternal: function(effect) {
|
afterSetup: function(effect) {
|
||||||
effect.element.makePositioned();
|
effect.element.makePositioned();
|
||||||
effect.element.down().makePositioned();
|
effect.element.down().makePositioned();
|
||||||
if (window.opera) effect.element.setStyle({top: ''});
|
if (window.opera) effect.element.setStyle({top: ''});
|
||||||
@ -744,12 +726,12 @@ Effect.SlideUp = function(element) {
|
|||||||
(effect.dims[0] - effect.element.clientHeight) + 'px' });
|
(effect.dims[0] - effect.element.clientHeight) + 'px' });
|
||||||
},
|
},
|
||||||
afterFinishInternal: function(effect) {
|
afterFinishInternal: function(effect) {
|
||||||
effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom});
|
effect.element.hide().undoClipping().undoPositioned();
|
||||||
effect.element.down().undoPositioned();
|
effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom});
|
||||||
}
|
}
|
||||||
}, arguments[1] || { })
|
}, arguments[1] || { })
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
// Bug in opera makes the TD containing this element expand for a instance after finish
|
// Bug in opera makes the TD containing this element expand for a instance after finish
|
||||||
Effect.Squish = function(element) {
|
Effect.Squish = function(element) {
|
||||||
@ -762,7 +744,7 @@ Effect.Squish = function(element) {
|
|||||||
effect.element.hide().undoClipping();
|
effect.element.hide().undoClipping();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.Grow = function(element) {
|
Effect.Grow = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
@ -836,7 +818,7 @@ Effect.Grow = function(element) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.Shrink = function(element) {
|
Effect.Shrink = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
@ -890,7 +872,7 @@ Effect.Shrink = function(element) {
|
|||||||
effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
|
effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
|
||||||
}, options)
|
}, options)
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.Pulsate = function(element) {
|
Effect.Pulsate = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
@ -903,7 +885,7 @@ Effect.Pulsate = function(element) {
|
|||||||
Object.extend(Object.extend({ duration: 2.0, from: 0,
|
Object.extend(Object.extend({ duration: 2.0, from: 0,
|
||||||
afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
|
afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
|
||||||
}, options), {transition: reverser}));
|
}, options), {transition: reverser}));
|
||||||
}
|
};
|
||||||
|
|
||||||
Effect.Fold = function(element) {
|
Effect.Fold = function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
@ -926,40 +908,37 @@ Effect.Fold = function(element) {
|
|||||||
}}, arguments[1] || { }));
|
}}, arguments[1] || { }));
|
||||||
};
|
};
|
||||||
|
|
||||||
Effect.Morph = Class.create();
|
Effect.Morph = Class.create(Effect.Base, {
|
||||||
Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
|
|
||||||
initialize: function(element) {
|
initialize: function(element) {
|
||||||
this.element = $(element);
|
this.element = $(element);
|
||||||
if (!this.element) throw(Effect._elementDoesNotExistError);
|
if (!this.element) throw(Effect._elementDoesNotExistError);
|
||||||
var options = Object.extend({
|
var options = Object.extend({
|
||||||
style: { }
|
style: { }
|
||||||
}, arguments[1] || { });
|
}, arguments[1] || { });
|
||||||
if (typeof options.style == 'string') {
|
|
||||||
if(options.style.indexOf(':') == -1) {
|
if (!Object.isString(options.style)) this.style = $H(options.style);
|
||||||
var cssText = '', selector = '.' + options.style;
|
else {
|
||||||
$A(document.styleSheets).reverse().each(function(styleSheet) {
|
if (options.style.include(':'))
|
||||||
if (styleSheet.cssRules) cssRules = styleSheet.cssRules;
|
this.style = options.style.parseStyle();
|
||||||
else if (styleSheet.rules) cssRules = styleSheet.rules;
|
else {
|
||||||
$A(cssRules).reverse().each(function(rule) {
|
this.element.addClassName(options.style);
|
||||||
if (selector == rule.selectorText) {
|
this.style = $H(this.element.getStyles());
|
||||||
cssText = rule.style.cssText;
|
this.element.removeClassName(options.style);
|
||||||
throw $break;
|
var css = this.element.getStyles();
|
||||||
}
|
this.style = this.style.reject(function(style) {
|
||||||
|
return style.value == css[style.key];
|
||||||
});
|
});
|
||||||
if (cssText) throw $break;
|
|
||||||
});
|
|
||||||
this.style = cssText.parseStyle();
|
|
||||||
options.afterFinishInternal = function(effect) {
|
options.afterFinishInternal = function(effect) {
|
||||||
effect.element.addClassName(effect.options.style);
|
effect.element.addClassName(effect.options.style);
|
||||||
effect.transforms.each(function(transform) {
|
effect.transforms.each(function(transform) {
|
||||||
if(transform.style != 'opacity')
|
|
||||||
effect.element.style[transform.style] = '';
|
effect.element.style[transform.style] = '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else this.style = options.style.parseStyle();
|
}
|
||||||
} else this.style = $H(options.style)
|
}
|
||||||
this.start(options);
|
this.start(options);
|
||||||
},
|
},
|
||||||
|
|
||||||
setup: function(){
|
setup: function(){
|
||||||
function parseColor(color){
|
function parseColor(color){
|
||||||
if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
|
if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
|
||||||
@ -1012,14 +991,14 @@ Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
|
|||||||
(transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() +
|
(transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() +
|
||||||
(Math.round(transform.originalValue[2]+
|
(Math.round(transform.originalValue[2]+
|
||||||
(transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() :
|
(transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() :
|
||||||
transform.originalValue + Math.round(
|
(transform.originalValue +
|
||||||
((transform.targetValue - transform.originalValue) * position) * 1000)/1000 + transform.unit;
|
(transform.targetValue - transform.originalValue) * position).toFixed(3) +
|
||||||
|
(transform.unit === null ? '' : transform.unit);
|
||||||
this.element.setStyle(style, true);
|
this.element.setStyle(style, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Effect.Transform = Class.create();
|
Effect.Transform = Class.create({
|
||||||
Object.extend(Effect.Transform.prototype, {
|
|
||||||
initialize: function(tracks){
|
initialize: function(tracks){
|
||||||
this.tracks = [];
|
this.tracks = [];
|
||||||
this.options = arguments[1] || { };
|
this.options = arguments[1] || { };
|
||||||
@ -1060,35 +1039,79 @@ Element.CSS_PROPERTIES = $w(
|
|||||||
|
|
||||||
Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
|
Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
|
||||||
|
|
||||||
|
String.__parseStyleElement = document.createElement('div');
|
||||||
String.prototype.parseStyle = function(){
|
String.prototype.parseStyle = function(){
|
||||||
var element = document.createElement('div');
|
var style, styleRules = $H();
|
||||||
element.innerHTML = '<div style="' + this + '"></div>';
|
if (Prototype.Browser.WebKit)
|
||||||
var style = element.childNodes[0].style, styleRules = $H();
|
style = new Element('div',{style:this}).style;
|
||||||
|
else {
|
||||||
|
String.__parseStyleElement.innerHTML = '<div style="' + this + '"></div>';
|
||||||
|
style = String.__parseStyleElement.childNodes[0].style;
|
||||||
|
}
|
||||||
|
|
||||||
Element.CSS_PROPERTIES.each(function(property){
|
Element.CSS_PROPERTIES.each(function(property){
|
||||||
if (style[property]) styleRules[property] = style[property];
|
if (style[property]) styleRules[property] = style[property];
|
||||||
});
|
});
|
||||||
if(Prototype.Browser.IE && this.indexOf('opacity') > -1) {
|
|
||||||
|
if (Prototype.Browser.IE && this.include('opacity'))
|
||||||
styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];
|
styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];
|
||||||
}
|
|
||||||
return styleRules;
|
return styleRules;
|
||||||
};
|
};
|
||||||
|
|
||||||
Element.morph = function(element, style) {
|
if (document.defaultView && document.defaultView.getComputedStyle) {
|
||||||
|
Element.getStyles = function(element) {
|
||||||
|
var css = document.defaultView.getComputedStyle($(element), null);
|
||||||
|
return Element.CSS_PROPERTIES.inject({ }, function(styles, property) {
|
||||||
|
styles[property] = css[property];
|
||||||
|
return styles;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
Element.getStyles = function(element) {
|
||||||
|
element = $(element);
|
||||||
|
var css = element.currentStyle, styles;
|
||||||
|
styles = Element.CSS_PROPERTIES.inject({ }, function(hash, property) {
|
||||||
|
hash[property] = css[property];
|
||||||
|
return hash;
|
||||||
|
});
|
||||||
|
if (!styles.opacity) styles.opacity = element.getOpacity();
|
||||||
|
return styles;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
Effect.Methods = {
|
||||||
|
morph: function(element, style) {
|
||||||
|
element = $(element);
|
||||||
new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { }));
|
new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { }));
|
||||||
return element;
|
return element;
|
||||||
|
},
|
||||||
|
visualEffect: function(element, effect, options) {
|
||||||
|
element = $(element)
|
||||||
|
var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1);
|
||||||
|
new Effect[klass](element, options);
|
||||||
|
return element;
|
||||||
|
},
|
||||||
|
highlight: function(element, options) {
|
||||||
|
element = $(element);
|
||||||
|
new Effect.Highlight(element, options);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
['getInlineOpacity','forceRerendering','setContentZoom',
|
$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+
|
||||||
'collectTextNodes','collectTextNodesIgnoreClass','morph'].each(
|
'pulsate shake puff squish switchOff dropOut').each(
|
||||||
function(f) { Element.Methods[f] = Element[f]; }
|
function(effect) {
|
||||||
|
Effect.Methods[effect] = function(element, options){
|
||||||
|
element = $(element);
|
||||||
|
Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Element.Methods.visualEffect = function(element, effect, options) {
|
$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each(
|
||||||
s = effect.dasherize().camelize();
|
function(f) { Effect.Methods[f] = Element[f]; }
|
||||||
effect_class = s.charAt(0).toUpperCase() + s.substring(1);
|
);
|
||||||
new Effect[effect_class](element, options);
|
|
||||||
return $(element);
|
|
||||||
};
|
|
||||||
|
|
||||||
Element.addMethods();
|
Element.addMethods(Effect.Methods);
|
||||||
@ -1,4 +1,4 @@
|
|||||||
// script.aculo.us scriptaculous.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
|
// script.aculo.us scriptaculous.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
|
||||||
|
|
||||||
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
//
|
//
|
||||||
@ -24,12 +24,12 @@
|
|||||||
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
||||||
|
|
||||||
var Scriptaculous = {
|
var Scriptaculous = {
|
||||||
Version: '1.7.1_beta3',
|
Version: '1.8.0_pre1',
|
||||||
require: function(libraryName) {
|
require: function(libraryName) {
|
||||||
// inserting via DOM fails in Safari 2.0, so brute force approach
|
// inserting via DOM fails in Safari 2.0, so brute force approach
|
||||||
document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
|
document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
|
||||||
},
|
},
|
||||||
REQUIRED_PROTOTYPE: '1.5.1',
|
REQUIRED_PROTOTYPE: '1.6.0',
|
||||||
load: function() {
|
load: function() {
|
||||||
function convertVersionString(versionString){
|
function convertVersionString(versionString){
|
||||||
var r = versionString.split('.');
|
var r = versionString.split('.');
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// script.aculo.us slider.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
|
// script.aculo.us slider.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
|
||||||
|
|
||||||
// Copyright (c) 2005-2007 Marty Haught, Thomas Fuchs
|
// Copyright (c) 2005-2007 Marty Haught, Thomas Fuchs
|
||||||
//
|
//
|
||||||
@ -18,7 +18,7 @@ Control.Slider.prototype = {
|
|||||||
initialize: function(handle, track, options) {
|
initialize: function(handle, track, options) {
|
||||||
var slider = this;
|
var slider = this;
|
||||||
|
|
||||||
if(handle instanceof Array) {
|
if (Object.isArray(handle)) {
|
||||||
this.handles = handle.collect( function(e) { return $(e) });
|
this.handles = handle.collect( function(e) { return $(e) });
|
||||||
} else {
|
} else {
|
||||||
this.handles = [$(handle)];
|
this.handles = [$(handle)];
|
||||||
@ -76,16 +76,15 @@ Control.Slider.prototype = {
|
|||||||
this.handles.each( function(h,i) {
|
this.handles.each( function(h,i) {
|
||||||
i = slider.handles.length-1-i;
|
i = slider.handles.length-1-i;
|
||||||
slider.setValue(parseFloat(
|
slider.setValue(parseFloat(
|
||||||
(slider.options.sliderValue instanceof Array ?
|
(Object.isArray(slider.options.sliderValue) ?
|
||||||
slider.options.sliderValue[i] : slider.options.sliderValue) ||
|
slider.options.sliderValue[i] : slider.options.sliderValue) ||
|
||||||
slider.range.start), i);
|
slider.range.start), i);
|
||||||
Element.makePositioned(h); // fix IE
|
h.makePositioned().observe("mousedown", slider.eventMouseDown);
|
||||||
Event.observe(h, "mousedown", slider.eventMouseDown);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Event.observe(this.track, "mousedown", this.eventMouseDown);
|
this.track.observe("mousedown", this.eventMouseDown);
|
||||||
Event.observe(document, "mouseup", this.eventMouseUp);
|
document.observe("mouseup", this.eventMouseUp);
|
||||||
Event.observe(document, "mousemove", this.eventMouseMove);
|
document.observe("mousemove", this.eventMouseMove);
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// script.aculo.us sound.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
|
// script.aculo.us sound.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
|
||||||
|
|
||||||
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
//
|
//
|
||||||
@ -39,16 +39,11 @@ Sound = {
|
|||||||
this.tracks[options.track].id++;
|
this.tracks[options.track].id++;
|
||||||
|
|
||||||
options.id = this.tracks[options.track].id;
|
options.id = this.tracks[options.track].id;
|
||||||
if (Prototype.Browser.IE) {
|
$$('body')[0].insert(
|
||||||
var sound = document.createElement('bgsound');
|
Prototype.Browser.IE ? new Element('bgsound',{
|
||||||
sound.setAttribute('id','sound_'+options.track+'_'+options.id);
|
id: 'sound_'+options.track+'_'+options.id,
|
||||||
sound.setAttribute('src',options.url);
|
src: options.url, loop: 1, autostart: true
|
||||||
sound.setAttribute('loop','1');
|
}) : Sound.template.evaluate(options));
|
||||||
sound.setAttribute('autostart','true');
|
|
||||||
$$('body')[0].appendChild(sound);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
new Insertion.Bottom($$('body')[0], Sound.template.evaluate(options));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// script.aculo.us unittest.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
|
// script.aculo.us unittest.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
|
||||||
|
|
||||||
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||||
// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
|
// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
|
||||||
@ -524,15 +524,19 @@ Test.setupBDDExtensionMethods = function(){
|
|||||||
shouldNotBe: 'assertReturnsFalse',
|
shouldNotBe: 'assertReturnsFalse',
|
||||||
shouldRespondTo: 'assertRespondsTo'
|
shouldRespondTo: 'assertRespondsTo'
|
||||||
};
|
};
|
||||||
Test.BDDMethods = {};
|
var makeAssertion = function(assertion, args, object) {
|
||||||
for(m in METHODMAP) {
|
this[assertion].apply(this,(args || []).concat([object]));
|
||||||
Test.BDDMethods[m] = eval(
|
|
||||||
'function(){'+
|
|
||||||
'var args = $A(arguments);'+
|
|
||||||
'var scope = args.shift();'+
|
|
||||||
'scope.'+METHODMAP[m]+'.apply(scope,(args || []).concat([this])); }');
|
|
||||||
}
|
}
|
||||||
[Array.prototype, String.prototype, Number.prototype].each(
|
|
||||||
|
Test.BDDMethods = {};
|
||||||
|
$H(METHODMAP).each(function(pair) {
|
||||||
|
Test.BDDMethods[pair.key] = function() {
|
||||||
|
var args = $A(arguments);
|
||||||
|
var scope = args.shift();
|
||||||
|
makeAssertion.apply(scope, [pair.value, args, this]); };
|
||||||
|
});
|
||||||
|
|
||||||
|
[Array.prototype, String.prototype, Number.prototype, Boolean.prototype].each(
|
||||||
function(p){ Object.extend(p, Test.BDDMethods) }
|
function(p){ Object.extend(p, Test.BDDMethods) }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user