Permalink
Browse files

Update Prototype to V1.4.0_pre11, script.aculo.us to [2502] and fix t…

…he rails generator to include the new .js files [Thomas Fuchs]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2503 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent a9de9c4 commit 7d101d58400acaff232091485c8e140f0a37cbaf @madrobby madrobby committed Oct 9, 2005
View
@@ -1,5 +1,7 @@
*SVN*
+* Update Prototype to V1.4.0_pre11, script.aculo.us to [2502] [Thomas Fuchs]
+
* Make assert_tag :children count appropriately. Closes #2181. [jamie@bravenet.com]
* Forced newer versions of RedCloth to use hard breaks [DHH]
@@ -60,7 +60,7 @@ Autocompleter.Base.prototype = {
update.style.position = 'absolute';
Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight});
}
- new Effect.Appear(update,{duration:0.15});
+ Effect.Appear(update,{duration:0.15});
};
this.options.onHide = this.options.onHide ||
function(element, update){ new Effect.Fade(update,{duration:0.15}) };
@@ -87,15 +87,18 @@ Autocompleter.Base.prototype = {
'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
this.iefix = $(this.update.id+'_iefix');
}
- if(this.iefix) {
- Position.clone(this.update, this.iefix);
- this.iefix.style.zIndex = 1;
- this.update.style.zIndex = 2;
- Element.show(this.iefix);
- }
+ if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
+ },
+
+ fixIEOverlapping: function() {
+ Position.clone(this.update, this.iefix);
+ this.iefix.style.zIndex = 1;
+ this.update.style.zIndex = 2;
+ Element.show(this.iefix);
},
hide: function() {
+ this.stopIndicator();
if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
if(this.iefix) Element.hide(this.iefix);
},
@@ -186,7 +189,7 @@ Autocompleter.Base.prototype = {
markPrevious: function() {
if(this.index > 0) this.index--
- else this.index = this.entryCcount-1;
+ else this.index = this.entryCount-1;
},
markNext: function() {
@@ -420,20 +423,7 @@ Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
// AJAX in-place editor
//
-// The constructor takes three parameters. The first is the element
-// that should support in-place editing. The second is the url to submit
-// the changed value to. The server should respond with the updated
-// value (the server might have post-processed it or validation might
-// have prevented it from changing). The third is a hash of options.
-//
-// Supported options are (all are optional and have sensible defaults):
-// - okText - The text of the submit button that submits the changed value
-// to the server (default: "ok")
-// - cancelText - The text of the link that cancels editing (default: "cancel")
-// - savingText - The text being displayed as the AJAX engine communicates
-// with the server (default: "Saving...")
-// - formId - The id given to the <form> element
-// (default: the id of the element to edit plus '-inplaceeditor')
+// see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
Ajax.InPlaceEditor = Class.create();
Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
@@ -461,6 +451,7 @@ Ajax.InPlaceEditor.prototype = {
handleLineBreaks: true,
loadingText: 'Loading...',
savingClassName: 'inplaceeditor-saving',
+ loadingClassName: 'inplaceeditor-loading',
formClassName: 'inplaceeditor-form',
highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
highlightendcolor: "#FFFFFF",
@@ -508,38 +499,37 @@ Ajax.InPlaceEditor.prototype = {
Element.hide(this.options.externalControl);
}
Element.hide(this.element);
- this.form = this.getForm();
+ this.createForm();
this.element.parentNode.insertBefore(this.form, this.element);
Field.focus(this.editField);
// stop the event to avoid a page refresh in Safari
if (arguments.length > 1) {
Event.stop(arguments[0]);
}
},
- getForm: function() {
- form = document.createElement("form");
- form.id = this.options.formId;
- Element.addClassName(form, this.options.formClassName)
- form.onsubmit = this.onSubmit.bind(this);
+ createForm: function() {
+ this.form = document.createElement("form");
+ this.form.id = this.options.formId;
+ Element.addClassName(this.form, this.options.formClassName)
+ this.form.onsubmit = this.onSubmit.bind(this);
- this.createEditField(form);
+ this.createEditField();
if (this.options.textarea) {
var br = document.createElement("br");
- form.appendChild(br);
+ this.form.appendChild(br);
}
okButton = document.createElement("input");
okButton.type = "submit";
okButton.value = this.options.okText;
- form.appendChild(okButton);
+ this.form.appendChild(okButton);
cancelLink = document.createElement("a");
cancelLink.href = "#";
cancelLink.appendChild(document.createTextNode(this.options.cancelText));
cancelLink.onclick = this.onclickCancel.bind(this);
- form.appendChild(cancelLink);
- return form;
+ this.form.appendChild(cancelLink);
},
hasHTMLLineBreaks: function(string) {
if (!this.options.handleLineBreaks) return false;
@@ -548,49 +538,57 @@ Ajax.InPlaceEditor.prototype = {
convertHTMLLineBreaks: function(string) {
return string.replace(/<br>/gi, "\n").replace(/<br\/>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<p>/gi, "");
},
- createEditField: function(form) {
- if (this.options.rows == 1 && !this.hasHTMLLineBreaks(this.getText())) {
+ createEditField: function() {
+ var text;
+ if(this.options.loadTextURL) {
+ text = this.options.loadingText;
+ } else {
+ text = this.getText();
+ }
+
+ if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
this.options.textarea = false;
var textField = document.createElement("input");
textField.type = "text";
textField.name = "value";
- textField.value = this.getText();
+ textField.value = text;
textField.style.backgroundColor = this.options.highlightcolor;
var size = this.options.size || this.options.cols || 0;
- if (size != 0)
- textField.size = size;
- form.appendChild(textField);
+ if (size != 0) textField.size = size;
this.editField = textField;
} else {
this.options.textarea = true;
var textArea = document.createElement("textarea");
textArea.name = "value";
- textArea.value = this.convertHTMLLineBreaks(this.getText());
+ textArea.value = this.convertHTMLLineBreaks(text);
textArea.rows = this.options.rows;
textArea.cols = this.options.cols || 40;
- form.appendChild(textArea);
this.editField = textArea;
}
- },
- getText: function() {
- if (this.options.loadTextURL) {
+
+ if(this.options.loadTextURL) {
this.loadExternalText();
- return this.options.loadingText;
- } else {
- return this.element.innerHTML;
}
+ this.form.appendChild(this.editField);
+ },
+ getText: function() {
+ return this.element.innerHTML;
},
loadExternalText: function() {
+ Element.addClassName(this.form, this.options.loadingClassName);
+ this.editField.disabled = true;
new Ajax.Request(
this.options.loadTextURL,
- {
+ Object.extend({
asynchronous: true,
onComplete: this.onLoadedExternalText.bind(this)
- }
+ }, this.options.ajaxOptions)
);
},
onLoadedExternalText: function(transport) {
- this.form.value.value = transport.responseText.stripTags();
+ Element.removeClassName(this.form, this.options.loadingClassName);
+ this.editField.disabled = false;
+ this.editField.value = transport.responseText.stripTags();
},
onclickCancel: function() {
this.onComplete();
@@ -606,7 +604,15 @@ Ajax.InPlaceEditor.prototype = {
return false;
},
onSubmit: function() {
- this.saving = true;
+ // onLoading resets these so we need to save them away for the Ajax call
+ var form = this.form;
+ var value = this.editField.value;
+
+ // do this first, sometimes the ajax call returns before we get a chance to switch on Saving...
+ // which means this will actually switch on Saving... *after* we've left edit mode causing Saving...
+ // to be displayed indefinitely
+ this.onLoading();
+
new Ajax.Updater(
{
success: this.element,
@@ -615,12 +621,11 @@ Ajax.InPlaceEditor.prototype = {
},
this.url,
Object.extend({
- parameters: this.options.callback(this.form, this.editField.value),
+ parameters: this.options.callback(form, value),
onComplete: this.onComplete.bind(this),
onFailure: this.onFailure.bind(this)
}, this.options.ajaxOptions)
);
- this.onLoading();
// stop the event to avoid a page refresh in Safari
if (arguments.length > 1) {
Event.stop(arguments[0]);
@@ -642,7 +647,7 @@ Ajax.InPlaceEditor.prototype = {
},
removeForm: function() {
if(this.form) {
- Element.remove(this.form);
+ if (this.form.parentNode) Element.remove(this.form);
this.form = null;
}
},
@@ -10,7 +10,7 @@ var Droppables = {
drops: [],
remove: function(element) {
- this.drops = this.drops.reject(function(e) { return e==element });
+ this.drops = this.drops.reject(function(d) { return d.element==element });
},
add: function(element) {
@@ -93,7 +93,7 @@ var Droppables = {
if (this.isAffected(Event.pointerX(event), Event.pointerY(event), element, this.last_active))
if (this.last_active.onDrop)
- this.last_active.onDrop(element, this.last_active.element);
+ this.last_active.onDrop(element, this.last_active.element, event);
},
reset: function() {
@@ -137,7 +137,11 @@ Draggable.prototype = {
}, arguments[1] || {});
this.element = $(element);
- this.handle = options.handle ? $(options.handle) : this.element;
+ if(options.handle && (typeof options.handle == 'string'))
+ this.handle = Element.Class.childrenWith(this.element, options.handle)[0];
+
+ if(!this.handle) this.handle = $(options.handle);
+ if(!this.handle) this.handle = this.element;
Element.makePositioned(this.element); // fix IE
@@ -147,7 +151,6 @@ Draggable.prototype = {
this.originalTop = this.currentTop();
this.originalX = this.element.offsetLeft;
this.originalY = this.element.offsetTop;
- this.originalZ = parseInt(this.element.style.zIndex || "0");
this.options = options;
@@ -230,7 +233,8 @@ Draggable.prototype = {
this.originalTop = this.currentTop();
}
- this.element.style.zIndex = this.originalZ;
+ if(this.options.zindex)
+ this.element.style.zIndex = this.originalZ;
if(this.options.endeffect)
this.options.endeffect(this.element);
@@ -271,8 +275,14 @@ Draggable.prototype = {
if(!this.dragging) {
var style = this.element.style;
this.dragging = true;
- if(style.position=="") style.position = "relative";
- style.zIndex = this.options.zindex;
+
+ if(Element.getStyle(this.element,'position')=='')
+ style.position = "relative";
+
+ if(this.options.zindex) {
+ this.options.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
+ style.zIndex = this.options.zindex;
+ }
if(this.options.ghosting) {
this._clone = this.element.cloneNode(true);
@@ -344,6 +354,7 @@ var Sortable = {
only: false,
hoverclass: null,
ghosting: false,
+ format: null,
onChange: function() {},
onUpdate: function() {}
}, arguments[1] || {});
@@ -494,11 +505,12 @@ var Sortable = {
var options = Object.extend({
tag: sortableOptions.tag,
only: sortableOptions.only,
- name: element.id
+ name: element.id,
+ format: sortableOptions.format || /^[^_]*_(.*)$/
}, arguments[1] || {});
- return $A(element.childNodes).collect( function(item) {
+ return $(this.findElements(element, options) || []).collect( function(item) {
return (encodeURIComponent(options.name) + "[]=" +
- encodeURIComponent(item.id.split("_")[1]));
+ encodeURIComponent(item.id.match(options.format) ? item.id.match(options.format)[1] : ''));
}).join("&");
}
}
Oops, something went wrong.

0 comments on commit 7d101d5

Please sign in to comment.