Author: a.izobov
Date: 2007-03-07 06:11:59 -0500 (Wed, 07 Mar 2007)
New Revision: 32
Modified:
trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
Log:
RFA-289 and RFA-292 fixed
Modified:
trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
---
trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-03-07
10:55:45 UTC (rev 31)
+++
trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-03-07
11:11:59 UTC (rev 32)
@@ -4,6 +4,7 @@
};
Suggestion.Base.prototype = {
baseInitialize: function(element, update, options) {
+ this.isOpera = (RichFaces.navigatorType() =="OPERA"?true:false);
this.element = $(element);
this.update = $(update);
this.hasFocus = false;
@@ -70,15 +71,67 @@
this.onKeyPressListener = this.onKeyPress.bindAsEventListener(this);
Event.observe(this.element, "keypress", this.onKeyPressListener);
+
+ if (this.isOpera) {
+ this.onKeyUpListener = this.onKeyUp.bindAsEventListener(this);
+ Event.observe(this.element, "keyup", this.onKeyUpListener);
+ this.upDown = 0;
+ }
},
+ onBoxKeyPress: function(event) {
+ if (this.upDown == 1) {
+ this.keyEvent = true;
+ this.markPrevious();
+ this.render();
+ } else if (this.upDown == 2) {
+ this.keyEvent = true;
+ this.markNext();
+ this.render();
+ }
+ },
+
+ cancelSubmit: function(event) {
+ Event.stop(event);
+ },
+
+ disableSubmit: function() {
+ if (this.isOpera) {
+ var el = this.element;
+ while (el.parentNode && (!el.tagName || (el.tagName.toUpperCase() !=
'FORM')))
+ el = el.parentNode;
+ if (el.tagName && (el.tagName.toUpperCase() == 'FORM')) {
+ this.parentForm = el;
+ this.onSubmitListener = this.cancelSubmit.bindAsEventListener(this);
+ Event.observe(el, "submit", this.onSubmitListener);
+ }
+ }
+ },
+
+ enableSubmit: function() {
+ if (this.isOpera) {
+ if (this.parentForm) {
+ Event.stopObserving(this.parentForm, "submit", this.onSubmitListener);
+ }
+ }
+ },
+
+ onKeyUp: function(event) {
+ if (this.upDown > 0) {
+ this.element.onkeypress=this.prevOnKeyPress;
+ }
+ this.upDown = 0;
+ },
+
show: function() {
if (Element.getStyle(this.update, 'display') == 'none')
this.options.onShow(this.element, this.update, this.options);
+ this.disableSubmit();
},
hide: function() {
this.stopIndicator();
if (Element.getStyle(this.update, 'display') != 'none')
this.options.onHide(this.element, this.update, this.options);
+ this.enableSubmit();
},
startIndicator: function() {
@@ -135,12 +188,22 @@
this.markPrevious();
this.render();
if (navigator.appVersion.indexOf('AppleWebKit') > 0)
Event.stop(event);
+ if (this.isOpera) {
+ this.upDown = 1;
+ this.prevOnKeyPress = this.element.onkeypress;
+ this.element.onkeypress =
this.onBoxKeyPress.bindAsEventListener(this);
+ }
return;
case Event.KEY_DOWN:
this.keyEvent = true;
this.markNext();
this.render();
if (navigator.appVersion.indexOf('AppleWebKit') > 0)
Event.stop(event);
+ if (this.isOpera) {
+ this.upDown = 2;
+ this.prevOnKeyPress = this.element.onkeypress;
+ this.element.onkeypress =
this.onBoxKeyPress.bindAsEventListener(this);
+ }
return;
}
else
Show replies by date