summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/effects/controls.js
diff options
context:
space:
mode:
authorxue <>2006-04-21 12:36:06 +0000
committerxue <>2006-04-21 12:36:06 +0000
commite392ecbf6e422825083bc7204eacb7090619a47c (patch)
tree8f2dcc8302f223ac2c71efd762417eddf84d62aa /framework/Web/Javascripts/effects/controls.js
parentc54a230a5926086ff1b69a0dd7e6352dbc0b40ff (diff)
Merge from 3.0 branch till 953.
Diffstat (limited to 'framework/Web/Javascripts/effects/controls.js')
-rw-r--r--framework/Web/Javascripts/effects/controls.js81
1 files changed, 63 insertions, 18 deletions
diff --git a/framework/Web/Javascripts/effects/controls.js b/framework/Web/Javascripts/effects/controls.js
index 3307f2e2..de0261ed 100644
--- a/framework/Web/Javascripts/effects/controls.js
+++ b/framework/Web/Javascripts/effects/controls.js
@@ -141,8 +141,8 @@ Autocompleter.Base.prototype = {
return;
}
else
- if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN)
- return;
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
+ (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return;
this.changed = true;
this.hasFocus = true;
@@ -152,6 +152,12 @@ Autocompleter.Base.prototype = {
setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
},
+ activate: function() {
+ this.changed = false;
+ this.hasFocus = true;
+ this.getUpdatedChoices();
+ },
+
onHover: function(event) {
var element = Event.findElement(event, 'LI');
if(this.index != element.autocompleteIndex)
@@ -310,7 +316,7 @@ Autocompleter.Base.prototype = {
Ajax.Autocompleter = Class.create();
Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
initialize: function(element, update, url, options) {
- this.baseInitialize(element, update, options);
+ this.baseInitialize(element, update, options);
this.options.asynchronous = true;
this.options.onComplete = this.onComplete.bind(this);
this.options.defaultParams = this.options.parameters || null;
@@ -477,9 +483,10 @@ Ajax.InPlaceEditor.prototype = {
formClassName: 'inplaceeditor-form',
highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
highlightendcolor: "#FFFFFF",
- externalControl: null,
+ externalControl: null,
submitOnBlur: false,
- ajaxOptions: {}
+ ajaxOptions: {},
+ evalScripts: false
}, options || {});
if(!this.options.formId && this.element.id) {
@@ -548,6 +555,7 @@ Ajax.InPlaceEditor.prototype = {
okButton = document.createElement("input");
okButton.type = "submit";
okButton.value = this.options.okText;
+ okButton.className = 'editor_ok_button';
this.form.appendChild(okButton);
}
@@ -556,6 +564,7 @@ Ajax.InPlaceEditor.prototype = {
cancelLink.href = "#";
cancelLink.appendChild(document.createTextNode(this.options.cancelText));
cancelLink.onclick = this.onclickCancel.bind(this);
+ cancelLink.className = 'editor_cancel';
this.form.appendChild(cancelLink);
}
},
@@ -584,6 +593,7 @@ Ajax.InPlaceEditor.prototype = {
textField.name = "value";
textField.value = text;
textField.style.backgroundColor = this.options.highlightcolor;
+ textField.className = 'editor_field';
var size = this.options.size || this.options.cols || 0;
if (size != 0) textField.size = size;
if (this.options.submitOnBlur)
@@ -597,6 +607,7 @@ Ajax.InPlaceEditor.prototype = {
textArea.value = this.convertHTMLLineBreaks(text);
textArea.rows = this.options.rows;
textArea.cols = this.options.cols || 40;
+ textArea.className = 'editor_field';
if (this.options.submitOnBlur)
textArea.onblur = this.onSubmit.bind(this);
this.editField = textArea;
@@ -649,19 +660,26 @@ Ajax.InPlaceEditor.prototype = {
// to be displayed indefinitely
this.onLoading();
- new Ajax.Updater(
- {
- success: this.element,
- // don't update on failure (this could be an option)
- failure: null
- },
- this.url,
- Object.extend({
- parameters: this.options.callback(form, value),
- onComplete: this.onComplete.bind(this),
- onFailure: this.onFailure.bind(this)
- }, this.options.ajaxOptions)
- );
+ if (this.options.evalScripts) {
+ new Ajax.Request(
+ this.url, Object.extend({
+ parameters: this.options.callback(form, value),
+ onComplete: this.onComplete.bind(this),
+ onFailure: this.onFailure.bind(this),
+ asynchronous:true,
+ evalScripts:true
+ }, this.options.ajaxOptions));
+ } else {
+ new Ajax.Updater(
+ { success: this.element,
+ // don't update on failure (this could be an option)
+ failure: null },
+ this.url, Object.extend({
+ parameters: this.options.callback(form, value),
+ onComplete: this.onComplete.bind(this),
+ onFailure: this.onFailure.bind(this)
+ }, this.options.ajaxOptions));
+ }
// stop the event to avoid a page refresh in Safari
if (arguments.length > 1) {
Event.stop(arguments[0]);
@@ -743,6 +761,33 @@ Ajax.InPlaceEditor.prototype = {
}
};
+Ajax.InPlaceCollectionEditor = Class.create();
+Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype);
+Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
+ createEditField: function() {
+ if (!this.cached_selectTag) {
+ var selectTag = document.createElement("select");
+ 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(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;
+ if(this.options.loadTextURL) this.loadExternalText();
+ this.form.appendChild(this.editField);
+ this.options.callback = function(form, value) {
+ return "value=" + encodeURIComponent(value);
+ }
+ }
+});
+
// Delayed observer, like Form.Element.Observer,
// but waits for delay after last key input
// Ideal for live-search fields