You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2006/08/01 19:44:01 UTC
svn commit: r427657 [40/42] - in /myfaces:
core/trunk/api/src/main/java/javax/faces/component/
core/trunk/api/src/test/java/javax/faces/
core/trunk/api/src/test/java/javax/faces/application/
core/trunk/api/src/test/java/javax/faces/component/ core/trun...
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/MenuItem.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/TimePicker.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/svg/Chart.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/svg/HslColorPicker.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/xml/Parse.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/xml/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/xml/domUtil.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/xml/htmlUtil.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/xml/svgUtil.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/ComboBox.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/FacesIO.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/FacesIO.js?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/FacesIO.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/FacesIO.js Tue Aug 1 10:43:28 2006
@@ -1,37 +1,37 @@
-dojo.provide("extensions.FacesIO");
-
-dojo.io.FacesTransport = new function() {
- this.canHandle = function(kwArgs) {
- return this.isClientStateSaving() && dojo.io.XMLHTTPTransport.canHandle(kwArgs);
- }
-
- this.bind = function(request) {
- if (this.isClientStateSaving()) {
- request.method = "post";
- this.addJsfState(request);
- }
- return dojo.io.XMLHTTPTransport.bind(request);
- }
-
- this.isClientStateSaving = function() {
- return dojo.byId("jsf_state") || dojo.byId("jsf_state_64");
- }
-
- this.addJsfState = function(request) {
- request.content = request.content || {};
- this.addInputValue(request.content, "jsf_state");
- this.addInputValue(request.content, "jsf_state_64");
- this.addInputValue(request.content, "jsf_tree");
- this.addInputValue(request.content, "jsf_tree_64");
- this.addInputValue(request.content, "jsf_viewid");
- }
-
- this.addInputValue = function (content, inputName) {
- var control = dojo.byId(inputName);
- if (!control || !control.value)
- return;
- content[inputName] = control.value;
- }
-
- dojo.io.transports.addTransport("FacesTransport");
+dojo.provide("extensions.FacesIO");
+
+dojo.io.FacesTransport = new function() {
+ this.canHandle = function(kwArgs) {
+ return this.isClientStateSaving() && dojo.io.XMLHTTPTransport.canHandle(kwArgs);
+ }
+
+ this.bind = function(request) {
+ if (this.isClientStateSaving()) {
+ request.method = "post";
+ this.addJsfState(request);
+ }
+ return dojo.io.XMLHTTPTransport.bind(request);
+ }
+
+ this.isClientStateSaving = function() {
+ return dojo.byId("jsf_state") || dojo.byId("jsf_state_64");
+ }
+
+ this.addJsfState = function(request) {
+ request.content = request.content || {};
+ this.addInputValue(request.content, "jsf_state");
+ this.addInputValue(request.content, "jsf_state_64");
+ this.addInputValue(request.content, "jsf_tree");
+ this.addInputValue(request.content, "jsf_tree_64");
+ this.addInputValue(request.content, "jsf_viewid");
+ }
+
+ this.addInputValue = function (content, inputName) {
+ var control = dojo.byId(inputName);
+ if (!control || !control.value)
+ return;
+ content[inputName] = control.value;
+ }
+
+ dojo.io.transports.addTransport("FacesTransport");
}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/FacesIO.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/picklist/resource/picklist.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/statechangednotifier/resource/stateChangedNotifier.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggest/resource/javascript/suggest.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggest/resource/javascript/suggest.js?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggest/resource/javascript/suggest.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggest/resource/javascript/suggest.js Tue Aug 1 10:43:28 2006
@@ -1,321 +1,321 @@
-var ACregExp = /\.|:/g;
-
-function calculateWidth(element) {
- if (navigator && navigator.userAgent.toLowerCase().indexOf("msie") == -1) {
- return element.offsetWidth - 2
- } else {
- return element.offsetWidth
- }
-}
-
-function calculateOffsetLeft(element) {
- return calculateOffset(element, "offsetLeft")
-}
-
-function calculateOffsetTop(element) {
- return calculateOffset(element, "offsetTop")
-}
-
-function calculateOffset(element, attr) {
- var offset = 0;
- while (element) {
- offset += element[attr];
- element = element.offsetParent
- }
- return offset
-}
-
-function getSelectionStart(fld) {
- var start = 0;
- if (fld.createTextRange) {
- var selection = document.selection.createRange().duplicate();
- selection.moveEnd("textedit", 1);
- start = fld.value.length - selection.text.length
- } else if (fld.setSelectionRange) {
- start = fld.selectionStart
- } else {
- start = -1
- }
- return start
-}
-
-function getSelectionLength(fld) {
- var selLength = 0;
- if (fld.createTextRange){
- var selection = document.selection.createRange().duplicate();
- selLength = selection.text.length
- } else if (fld.setSelectionRange) {
- selLength = fld.selectionEnd - fld.selectionStart
- } else {
- selLength = -1
- }
- return selLength
-}
-
-function unSelect(fld) {
- if (fld.createTextRange) {
- var range = fld.createTextRange();
- range.moveStart("character", fld.value.length);
- range.select();
- } else if (fld.setSelectionRange) {
- fld.setSelectionRange(fld.value.length, fld.value.length)
- }
-}
-
-function highlightACDiv(div, fldId, index) {
- fldId = fldId.replace(ACregExp, '_');
- if (eval(fldId + "Row") != -1) {
- var currDiv = eval(fldId + "RowDiv");
- currDiv.className = eval(fldId + "NormalClass");
- }
-
- div.className += " " + eval(fldId + "HighlightClass");
- eval(fldId + "Row = index");
- eval(fldId + "RowDiv = div");
-}
-
-function unHighlightACDiv(div, fldId) {
- fldId = fldId.replace(ACregExp, '_');
- div.className = eval(fldId + "NormalClass");
- eval(fldId + "Row = -1");
- eval(fldId + "RowDiv = null");
- eval(fldId + "MinRow = 0");
-}
-
-function selectACDiv(fldId) {
- var fld = document.getElementById(fldId);
-
- var div = document.getElementById("AC" + fldId);
-
- fldId = fldId.replace(ACregExp, '_');
- var selected = div.getElementsByTagName("DIV")[eval(fldId + "Row")];
- var text = selected.firstChild.data;
-
- fld.value = text;
-
- unSelect(fld);
-}
-
-function filterACList(fld, backspace) {
- var srchText = fld.value;
-
- var selStart = getSelectionStart(fld);
- if (selStart > 0 && getSelectionLength(fld) > 0)
- srchText = srchText.substring(0, selStart);
-
- var div = document.getElementById("AC" + fld.id);
- var options = div.getElementsByTagName("DIV");
- var fldId = fld.id.replace(ACregExp, '_');
-
- var caseSensitive = eval(fldId + "CaseSensitive");
- if (!caseSensitive) srchText = srchText.toLowerCase();
-
- var srchTextLen = srchText.length;
- var found = false;
- var optLen = options.length;
- for (var ii=0; ii<optLen; ii++) {
- var optText = options[ii].firstChild.data;
- if (!caseSensitive) optText = optText.toLowerCase();
- if (optText.substr(0, srchTextLen) == srchText) {
- options[ii].style.display = "block";
- if (!found && !backspace) {
- eval(fldId + "MinRow = " + ii);
- highlightACDiv(options[ii], fld.id, ii);
- autoComplete(fld, options[ii])
- }
- found = true;
- if (srchTextLen == 0 || backspace) unHighlightACDiv(options[ii], fld.id)
- } else {
- options[ii].style.display = "none"
- }
- }
-
- if (found) {
- div.style.visibility = "visible"
- var divShim = document.getElementById(fldId + "Shim");
- if (divShim)
- divShim.style.visibility = "visible";
- }
- else {
- var currRow = eval(fldId + "RowDiv");
- if (currRow)
- unHighlightACDiv(currRow, fld.id);
- blurACfld(fld)
- }
-}
-
-function autoComplete(fld, div) {
- var currLen = fld.value.length;
-
- if (getSelectionStart(fld) != currLen) return;
-
- fld.value = div.firstChild.data;
-
- if (fld.createTextRange) {
- var range = fld.createTextRange();
- range.moveStart("character", currLen);
- range.select()
- } else if (fld.setSelectionRange) {
- fld.setSelectionRange(currLen, fld.value.length)
- }
-}
-
-function blurThenGetFocus(fld) {
- fld.blur();
- setTimeout("setACfieldFocus('" + fld.id + "')", 10);
- return
-}
-
-function setACfieldFocus(fldId) {
- document.getElementById(fldId).focus();
-}
-
-function handleACkeyDown(fld, event) {
- var div = document.getElementById("AC" + fld.id);
-
- if (div.style.visibility == "hidden") return true;
-
- if (!event && window.event) event = window.event;
-
- var fldId = fld.id.replace(ACregExp, '_');
-
- var keyCode = event.keyCode;
- if (keyCode == 40 || keyCode == 38) {
- blurThenGetFocus(fld);
-
- var options = div.getElementsByTagName("DIV");
- var currRow = eval(fldId + "Row");
- var minRow = eval(fldId + "MinRow");
- var dispRows = eval(fldId + "DisplayRows");
- var scroll = eval(fldId + "Scroll");
-
- var newRow = eval(fldId + "Row") + ((keyCode == 40) ? 1 : -1);
-
- if (!scroll && newRow >= (minRow + dispRows))
- return false;
-
- if (newRow <= -1)
- newRow = ((scroll) ? options.length : (minRow + dispRows)) - 1;
-
- while (options[newRow] && options[newRow].style.display == "none") {
- newRow = newRow + ((keyCode == 40) ? 1 : -1);
- }
-
- if (options[newRow]) {
- highlightACDiv(options[newRow], fld.id, newRow);
- selectACDiv(fld.id);
-
- if (newRow >= (minRow + dispRows))
- options[newRow - dispRows + 1].scrollIntoView()
- }
-
- return false;
- } else if (keyCode == 13 || keyCode == 3) {
- unSelect(fld);
- fld.blur();
- div.style.visibility = "hidden";
- var divShim = document.getElementById(fldId + "Shim");
- if (divShim)
- divShim.style.visibility = "hidden";
- return false;
- } else
- return true;
-}
-
-function handleACkeyUp(fld, event) {
- if (!event && window.event) event = window.event;
-
- var fldId = fld.id.replace(ACregExp, '_');
-
- var backspace = false;
- var reset = false;
- switch (event.keyCode) {
- case 8:
- case 46:
- backspace = true;
- break;
- case 38:
- case 40:
- return false;
- case 33:
- case 34:
- case 35:
- case 36:
- case 37:
- case 39:
- case 45:
- reset = true;
- break;
- default:
- break
- }
-
- if (!reset) {
- filterACList(fld, backspace);
- } else {
- if (eval(fldId + "Row") != -1)
- unHighlightACDiv(eval(fldId + "RowDiv"), fld.id);
- }
-
- AChandlingKeyUp = false;
-}
-
-function blurACfld(fld) {
- var listDiv = document.getElementById("AC" + fld.id);
-
- listDiv.style.visibility = "hidden";
-
- var fldId = fld.id.replace(ACregExp, '_');
-
- var divShim = document.getElementById(fldId + "Shim");
- if (divShim)
- divShim.style.visibility = "hidden";
-
- var hiddenFldId = eval(fldId + "HiddenFldId");
- var hiddenFld = document.getElementById(hiddenFldId);
- if (!hiddenFld) return;
-
- var selValue = -1; // if no match, set the value to -1
- var rowDiv = eval(fldId + "RowDiv");
- if (rowDiv)
- selValue = rowDiv.id.substr(hiddenFldId.length);
-
- hiddenFld.value = selValue;
-}
-
-function setACdivs() {
- var allDivs = document.getElementsByTagName("DIV");
- for (var ii=0; ii<allDivs.length; ii++) {
- if (allDivs[ii].id.indexOf("AC") != 0) continue;
-
- var fldId = allDivs[ii].id.substr(2);
- var fld = document.getElementById(fldId);
- fldId = fldId.replace(ACregExp, '_');
- allDivs[ii].style.border = "black 1px solid";
- allDivs[ii].style.zIndex = 100;
- allDivs[ii].style.backgroundColor = "white";
- allDivs[ii].style.visibility = "hidden";
- allDivs[ii].style.position = "absolute";
- allDivs[ii].style.overflow = (eval(fldId + "Scroll")) ? "auto" : "hidden";
- allDivs[ii].style.width = calculateWidth(fld) + "px";
- allDivs[ii].style.height = 15 * eval(fldId + "DisplayRows") + "px";
- allDivs[ii].style.top = calculateOffsetTop(fld) + fld.offsetHeight;
- allDivs[ii].style.left = calculateOffsetLeft(fld);
-
- var divShim = document.getElementById(fldId + "Shim");
- if (divShim)
- {
- divShim.style.width = allDivs[ii].style.width;
- divShim.style.height = allDivs[ii].style.height;
- divShim.style.left = allDivs[ii].style.left;
- divShim.style.top = allDivs[ii].style.top;
- divShim.style.zIndex = allDivs[ii].style.zIndex - 1;
- divShim.style.visibility = "hidden";
- }
- }
-}
-
-if (window.attachEvent)
- window.attachEvent("onload", setACdivs);
-else if (window.addEventListener)
- window.addEventListener("load", setACdivs, false);
+var ACregExp = /\.|:/g;
+
+function calculateWidth(element) {
+ if (navigator && navigator.userAgent.toLowerCase().indexOf("msie") == -1) {
+ return element.offsetWidth - 2
+ } else {
+ return element.offsetWidth
+ }
+}
+
+function calculateOffsetLeft(element) {
+ return calculateOffset(element, "offsetLeft")
+}
+
+function calculateOffsetTop(element) {
+ return calculateOffset(element, "offsetTop")
+}
+
+function calculateOffset(element, attr) {
+ var offset = 0;
+ while (element) {
+ offset += element[attr];
+ element = element.offsetParent
+ }
+ return offset
+}
+
+function getSelectionStart(fld) {
+ var start = 0;
+ if (fld.createTextRange) {
+ var selection = document.selection.createRange().duplicate();
+ selection.moveEnd("textedit", 1);
+ start = fld.value.length - selection.text.length
+ } else if (fld.setSelectionRange) {
+ start = fld.selectionStart
+ } else {
+ start = -1
+ }
+ return start
+}
+
+function getSelectionLength(fld) {
+ var selLength = 0;
+ if (fld.createTextRange){
+ var selection = document.selection.createRange().duplicate();
+ selLength = selection.text.length
+ } else if (fld.setSelectionRange) {
+ selLength = fld.selectionEnd - fld.selectionStart
+ } else {
+ selLength = -1
+ }
+ return selLength
+}
+
+function unSelect(fld) {
+ if (fld.createTextRange) {
+ var range = fld.createTextRange();
+ range.moveStart("character", fld.value.length);
+ range.select();
+ } else if (fld.setSelectionRange) {
+ fld.setSelectionRange(fld.value.length, fld.value.length)
+ }
+}
+
+function highlightACDiv(div, fldId, index) {
+ fldId = fldId.replace(ACregExp, '_');
+ if (eval(fldId + "Row") != -1) {
+ var currDiv = eval(fldId + "RowDiv");
+ currDiv.className = eval(fldId + "NormalClass");
+ }
+
+ div.className += " " + eval(fldId + "HighlightClass");
+ eval(fldId + "Row = index");
+ eval(fldId + "RowDiv = div");
+}
+
+function unHighlightACDiv(div, fldId) {
+ fldId = fldId.replace(ACregExp, '_');
+ div.className = eval(fldId + "NormalClass");
+ eval(fldId + "Row = -1");
+ eval(fldId + "RowDiv = null");
+ eval(fldId + "MinRow = 0");
+}
+
+function selectACDiv(fldId) {
+ var fld = document.getElementById(fldId);
+
+ var div = document.getElementById("AC" + fldId);
+
+ fldId = fldId.replace(ACregExp, '_');
+ var selected = div.getElementsByTagName("DIV")[eval(fldId + "Row")];
+ var text = selected.firstChild.data;
+
+ fld.value = text;
+
+ unSelect(fld);
+}
+
+function filterACList(fld, backspace) {
+ var srchText = fld.value;
+
+ var selStart = getSelectionStart(fld);
+ if (selStart > 0 && getSelectionLength(fld) > 0)
+ srchText = srchText.substring(0, selStart);
+
+ var div = document.getElementById("AC" + fld.id);
+ var options = div.getElementsByTagName("DIV");
+ var fldId = fld.id.replace(ACregExp, '_');
+
+ var caseSensitive = eval(fldId + "CaseSensitive");
+ if (!caseSensitive) srchText = srchText.toLowerCase();
+
+ var srchTextLen = srchText.length;
+ var found = false;
+ var optLen = options.length;
+ for (var ii=0; ii<optLen; ii++) {
+ var optText = options[ii].firstChild.data;
+ if (!caseSensitive) optText = optText.toLowerCase();
+ if (optText.substr(0, srchTextLen) == srchText) {
+ options[ii].style.display = "block";
+ if (!found && !backspace) {
+ eval(fldId + "MinRow = " + ii);
+ highlightACDiv(options[ii], fld.id, ii);
+ autoComplete(fld, options[ii])
+ }
+ found = true;
+ if (srchTextLen == 0 || backspace) unHighlightACDiv(options[ii], fld.id)
+ } else {
+ options[ii].style.display = "none"
+ }
+ }
+
+ if (found) {
+ div.style.visibility = "visible"
+ var divShim = document.getElementById(fldId + "Shim");
+ if (divShim)
+ divShim.style.visibility = "visible";
+ }
+ else {
+ var currRow = eval(fldId + "RowDiv");
+ if (currRow)
+ unHighlightACDiv(currRow, fld.id);
+ blurACfld(fld)
+ }
+}
+
+function autoComplete(fld, div) {
+ var currLen = fld.value.length;
+
+ if (getSelectionStart(fld) != currLen) return;
+
+ fld.value = div.firstChild.data;
+
+ if (fld.createTextRange) {
+ var range = fld.createTextRange();
+ range.moveStart("character", currLen);
+ range.select()
+ } else if (fld.setSelectionRange) {
+ fld.setSelectionRange(currLen, fld.value.length)
+ }
+}
+
+function blurThenGetFocus(fld) {
+ fld.blur();
+ setTimeout("setACfieldFocus('" + fld.id + "')", 10);
+ return
+}
+
+function setACfieldFocus(fldId) {
+ document.getElementById(fldId).focus();
+}
+
+function handleACkeyDown(fld, event) {
+ var div = document.getElementById("AC" + fld.id);
+
+ if (div.style.visibility == "hidden") return true;
+
+ if (!event && window.event) event = window.event;
+
+ var fldId = fld.id.replace(ACregExp, '_');
+
+ var keyCode = event.keyCode;
+ if (keyCode == 40 || keyCode == 38) {
+ blurThenGetFocus(fld);
+
+ var options = div.getElementsByTagName("DIV");
+ var currRow = eval(fldId + "Row");
+ var minRow = eval(fldId + "MinRow");
+ var dispRows = eval(fldId + "DisplayRows");
+ var scroll = eval(fldId + "Scroll");
+
+ var newRow = eval(fldId + "Row") + ((keyCode == 40) ? 1 : -1);
+
+ if (!scroll && newRow >= (minRow + dispRows))
+ return false;
+
+ if (newRow <= -1)
+ newRow = ((scroll) ? options.length : (minRow + dispRows)) - 1;
+
+ while (options[newRow] && options[newRow].style.display == "none") {
+ newRow = newRow + ((keyCode == 40) ? 1 : -1);
+ }
+
+ if (options[newRow]) {
+ highlightACDiv(options[newRow], fld.id, newRow);
+ selectACDiv(fld.id);
+
+ if (newRow >= (minRow + dispRows))
+ options[newRow - dispRows + 1].scrollIntoView()
+ }
+
+ return false;
+ } else if (keyCode == 13 || keyCode == 3) {
+ unSelect(fld);
+ fld.blur();
+ div.style.visibility = "hidden";
+ var divShim = document.getElementById(fldId + "Shim");
+ if (divShim)
+ divShim.style.visibility = "hidden";
+ return false;
+ } else
+ return true;
+}
+
+function handleACkeyUp(fld, event) {
+ if (!event && window.event) event = window.event;
+
+ var fldId = fld.id.replace(ACregExp, '_');
+
+ var backspace = false;
+ var reset = false;
+ switch (event.keyCode) {
+ case 8:
+ case 46:
+ backspace = true;
+ break;
+ case 38:
+ case 40:
+ return false;
+ case 33:
+ case 34:
+ case 35:
+ case 36:
+ case 37:
+ case 39:
+ case 45:
+ reset = true;
+ break;
+ default:
+ break
+ }
+
+ if (!reset) {
+ filterACList(fld, backspace);
+ } else {
+ if (eval(fldId + "Row") != -1)
+ unHighlightACDiv(eval(fldId + "RowDiv"), fld.id);
+ }
+
+ AChandlingKeyUp = false;
+}
+
+function blurACfld(fld) {
+ var listDiv = document.getElementById("AC" + fld.id);
+
+ listDiv.style.visibility = "hidden";
+
+ var fldId = fld.id.replace(ACregExp, '_');
+
+ var divShim = document.getElementById(fldId + "Shim");
+ if (divShim)
+ divShim.style.visibility = "hidden";
+
+ var hiddenFldId = eval(fldId + "HiddenFldId");
+ var hiddenFld = document.getElementById(hiddenFldId);
+ if (!hiddenFld) return;
+
+ var selValue = -1; // if no match, set the value to -1
+ var rowDiv = eval(fldId + "RowDiv");
+ if (rowDiv)
+ selValue = rowDiv.id.substr(hiddenFldId.length);
+
+ hiddenFld.value = selValue;
+}
+
+function setACdivs() {
+ var allDivs = document.getElementsByTagName("DIV");
+ for (var ii=0; ii<allDivs.length; ii++) {
+ if (allDivs[ii].id.indexOf("AC") != 0) continue;
+
+ var fldId = allDivs[ii].id.substr(2);
+ var fld = document.getElementById(fldId);
+ fldId = fldId.replace(ACregExp, '_');
+ allDivs[ii].style.border = "black 1px solid";
+ allDivs[ii].style.zIndex = 100;
+ allDivs[ii].style.backgroundColor = "white";
+ allDivs[ii].style.visibility = "hidden";
+ allDivs[ii].style.position = "absolute";
+ allDivs[ii].style.overflow = (eval(fldId + "Scroll")) ? "auto" : "hidden";
+ allDivs[ii].style.width = calculateWidth(fld) + "px";
+ allDivs[ii].style.height = 15 * eval(fldId + "DisplayRows") + "px";
+ allDivs[ii].style.top = calculateOffsetTop(fld) + fld.offsetHeight;
+ allDivs[ii].style.left = calculateOffsetLeft(fld);
+
+ var divShim = document.getElementById(fldId + "Shim");
+ if (divShim)
+ {
+ divShim.style.width = allDivs[ii].style.width;
+ divShim.style.height = allDivs[ii].style.height;
+ divShim.style.left = allDivs[ii].style.left;
+ divShim.style.top = allDivs[ii].style.top;
+ divShim.style.zIndex = allDivs[ii].style.zIndex - 1;
+ divShim.style.visibility = "hidden";
+ }
+ }
+}
+
+if (window.attachEvent)
+ window.attachEvent("onload", setACdivs);
+else if (window.addEventListener)
+ window.addEventListener("load", setACdivs, false);
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggest/resource/javascript/suggest.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js Tue Aug 1 10:43:28 2006
@@ -1,779 +1,779 @@
-/**
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-org_apache_myfaces_TableSuggest = function(ajaxUrl,
- millisBetweenKeyUps,
- startChars,
- charset,
- acceptValueToField,
- fieldNames,
- styleClassOptions)
-{
- this.tablePagesCollection = new dojo.collections.ArrayList();
-
- this.inputField = null;
-
- this.inputFieldId = null;
- this.popUp = null;
- this.url = ajaxUrl;
- this.charset = charset;
- this.firstHighlightedElem = null;
- this.actualHighlightedElem = null;
-
- this.blurTimer = null;
- this.validateInput = true;
- this.saveOldValues = true;
- this.oldValues = null;
-
- this.iframe = null;
- this.timeOut = null;
-
- this.data = null;
- this.columnHeaders = null;
-
- this.startChars = startChars;
- this.acceptValueToField = acceptValueToField;
- this.lastKeyPressTime = new Date();
- this.millisBetweenKeyUps = millisBetweenKeyUps;
- this.scrollingRow = 0;
- this.fieldNames = fieldNames;
-
-
- this.tableStyleClass = styleClassOptions.tableStyleClass;
- this.columnHoverClass = styleClassOptions.columnHoverClass;
- this.columnOutClass = styleClassOptions.columnOutClass;
-
-
- //puting the values from the choosen row into the fields
- org_apache_myfaces_TableSuggest.prototype.putValueToField = function(trElem)
- {
- if (trElem)
- {
- this.scrollOverflowDiv(trElem);
-
- for (j = 0; j < trElem.childNodes.length; j++)
- {
- var tdElem = trElem.childNodes[j];
-
- for (a = 0; a < tdElem.childNodes.length; a++)
- {
- var spanElem = tdElem.childNodes[a];
-
- if (spanElem.id)
- {
- var idToPutValue = spanElem.id.substr(10);
- var elemToPutValue = dojo.byId(idToPutValue);
-
- if (elemToPutValue)
- {
- if (dojo.dom.getTagName(elemToPutValue) == "input")
- {
- elemToPutValue.value = spanElem.innerHTML;
- if (elemToPutValue.onchange)
- {
- elemToPutValue.onchange();
- }
- }
- else if (dojo.dom.getTagName(elemToPutValue) == "select")
- {
- for (i = 0; i < elemToPutValue.options.length; i++)
- {
- var optionValue = spanElem.innerHTML;
-
- if (elemToPutValue.options[i].value == optionValue)
- elemToPutValue.options[i].selected = true;
- }
- }
- }
- }
- }
- }
- }
- this.inputField.focus();
- };
-
-
- org_apache_myfaces_TableSuggest.prototype.typeAhead = function(suggestion)
- {
- var len = this.inputField.value.length;
- this.inputField.value = suggestion;
-
- if (this.inputField.createTextRange)
- {
- var range = this.inputField.createTextRange();
- range.moveStart("character", len);
- range.moveEnd("character", suggestion.length - len);
- range.select();
- }
- else if (this.inputField.setSelectionRange) {
- this.inputField.setSelectionRange(len, suggestion.length);
- }
- }
-
- org_apache_myfaces_TableSuggest.prototype.scrollOverflowDiv = function(trElem)
- {
- if(this.popUp.style.overflow == "auto")
- {
- var popUpStyleHeight = this.popUp.style.height;
- var popUpHeight = dojo.style.getOuterHeight(this.popUp);
- var popUpContentHeight = dojo.style.getOuterHeight(this.popUp.childNodes[0]);
-
- if(popUpStyleHeight != "" && popUpContentHeight > popUpHeight)
- {
- var prevElem = dojo.dom.prevElement(trElem);
-
- if (prevElem)
- {
- this.scrollingRow++;
-
- if (this.scrollingRow >= 4)
- {
- var prevYPos = dojo.html.getScrollTop();
- window.location.href = "#" + prevElem.id;
- var currentYPos = dojo.html.getScrollTop();
- //smoothScroll(prevYPos, currentYPos);
- this.inputField.focus();
- }
- }
- }
- }
- };
-
- org_apache_myfaces_TableSuggest.prototype.smoothYScroll = function(prevYPos,currentYPos)
- {
- var yDiff = prevYPos-currentYPos;
-
- while(yDiff < 0){
- window.scrollBy(0,-50);
- dojo.lang.setTimeout('org_apache_myfaces_TableSuggest.prototype.smoothYScroll('+prevYPos+','+currentYPos+')',1000);
- yDiff = yDiff+50;
- }
- };
-
- org_apache_myfaces_TableSuggest.prototype.handleRequestResponse = function(tableSuggest)
- {
-
- if (this.timeOut != null)
- {
- clearTimeout(this.timeOut);
- this.timeOut = null;
- }
-
- var idValuePair = "&" + this.inputField.id + "=" + this.inputField.value;
-
- this.timeOut = setTimeout(function() {
-
- this.firstHighlightedElem = null;
- this.actualHighlightedElem = null;
-
- dojo.io.bind(
- {
- url: tableSuggest.url + idValuePair,
- handle: function(type, data, evt) {
-
- dojo.debug("after response");
- //if(data) dojo.debug(data);
-
- if(type == "load" && data)
- {
- tableSuggest.parseAjaxResponse(data);
- tableSuggest.renderDropdown();
- return;
-
- dojo.debug("response successful");
- var tablePagesArray = dojo.html.createNodesFromText(data);
- var collection = tableSuggest.tablePagesCollection;
-
- var firstPage = null;
- var firstPageField = null;
-
- dojo.dom.removeChildren(tableSuggest.popUp);
-
- collection.clear();
-
- for(k=0;k<tablePagesArray.length;k++)
- {
- if(k==0)
- {
- firstPage = tablePagesArray[k];
- firstPageField = tablePagesArray[k+1];
- dojo.dom.insertAtPosition(firstPage, tableSuggest.popUp, "first");
- dojo.dom.insertAtPosition(firstPageField, tableSuggest.popUp, "last");
- k++;
-
- if(firstPage.rows && firstPage.rows.length == 2)
- {
- var row = firstPage.rows[1];
- tableSuggest.putValueToField(row);
- }
- }
- else
- {
- collection.add(tablePagesArray[k]);
- }
- }
-
- tableSuggest.handleIFrame();
- }
- else if(type == "error")
- {
- dojo.debug("error during response");
- //dojo.debug(data);
- // here, data is our error object
- }
- }, //end function
- mimetype: "text/xml",
- content: { charset: tableSuggest.charset }
- }); //end bind
-
- }, this.millisBetweenKeyUps);
- };
-
- //handles the user pressing the 'Up-Arrow' key
- org_apache_myfaces_TableSuggest.prototype.handleUpKey = function()
- {
- var prevElem = dojo.dom.prevElement(this.actualHighlightedElem);
-
- if(prevElem)
- {
- if(dojo.dom.getTagName(prevElem) == "tr")
- {
- this.putValueToField(prevElem);
- this.addOutClass(this.actualHighlightedElem);
- this.addHoverClass(prevElem);
- this.actualHighlightedElem = prevElem;
- }
- }
- else
- {
- var table = dojo.html.getFirstAncestorByTag(this.actualHighlightedElem,"table");
-
- if(table)
- {
- this.previousPage(table);
- this.addOutClass(this.actualHighlightedElem);
- this.actualHighlightedElem = this.getLastRowElem(this.popUp);
- this.putValueToField(this.actualHighlightedElem);
- this.addHoverClass(this.actualHighlightedElem);
- }
- else
- dojo.debug("could not move to next item in table, wrong item is");dojo.debug(nextElem);
- }
- }
- }
-
- //parses the XML ajax response data
- org_apache_myfaces_TableSuggest.prototype.parseAjaxResponse = function(data)
- {
- var root = data.documentElement;
-
- //parse the column names of the table to be rendered
- var columnHeaders = root.getElementsByTagName("columnHeader");
- var columnHeadersArray = new Array();
- for (var i = 0; i < columnHeaders.length; i++)
- {
- columnHeadersArray[i] = columnHeaders[i].firstChild.nodeValue;
- }
- this.columnHeaders = columnHeadersArray;
-
- //parse the individual data items
- var items = root.getElementsByTagName("item");
- var itemsArray = new Array();
-
- for (var i = 0; i < items.length; i++)
- {
- var currentItem = items[i];
- var columnsArray = new Array();
-
- for (var j = 0; j < currentItem.childNodes.length; j++)
- {
- var currentColumn = currentItem.childNodes[j];
- var column = new Object();
-
- var currentChild = currentColumn.firstChild;
-
- do {
- column[currentChild.tagName] = currentChild.firstChild.nodeValue;
- } while (currentChild = currentChild.nextSibling);
-
- columnsArray[j] = column;
- }
-
- itemsArray[i] = columnsArray;
- }
- this.data = itemsArray;
- }
-
- //Render the ajax drop-down window
- org_apache_myfaces_TableSuggest.prototype.renderDropdown = function()
- {
- dojo.dom.removeChildren(this.popUp);
-
- //if no data exists
- if (this.data == null || this.data.length == 0)
- {
- this.resetSettings();
- return;
- }
-
- //create a table for the suggesting items
- var suggestTable = document.createElement("table");
- //suggestTable.setAttribute("class", this.tableStyleClass);
- suggestTable.className = "ajaxTable";
-
- var tbody = document.createElement("tbody");
- suggestTable.appendChild(tbody);
-
- var thead = suggestTable.createTHead();
- var tr, td, tn, span;
-
- //add the column Headers
- tr = thead.insertRow(0);
-
- for (var i = 0; i < this.columnHeaders.length; i++)
- {
- td = tr.insertCell(tr.cells.length);
- tn = document.createTextNode(this.columnHeaders[i]);
- td.appendChild(tn);
- }
-
- var tableSuggestAjax = this;
-
- //adding the data items
- for (var i = 0; i < this.data.length; i++)
- {
- var columnsArray = this.data[i];
- tr = tbody.insertRow(tbody.rows.length);
-
- tr.onmouseover = function() { this.className = tableSuggestAjax.columnHoverClass; }
- tr.onmouseout = function() { this.className= tableSuggestAjax.columnOutClass; }
- tr.id = "row" + (i + 1) + this.inputFieldId;
- var tableSuggest = this;
- tr.onclick = function(event) {
- var evt = (event) ? event : window.event;
-
- //find the enclosing tr element
- var target = evt.target || evt.srcElement;
- var obj = target.parentNode;
- while (obj.tagName != 'TR')
- {
- obj = obj.parentNode;
- }
-
- tableSuggest.putValueToField(obj);
- }
-
- for (var j = 0; j < columnsArray.length; j++)
- {
- td = tr.insertCell(tr.cells.length);
-
- //DEBUG
- if (typeof columnsArray[j].forText != "undefined")
- {
- span = document.createElement("span");
- //span.setAttribute("id", "putValueTo" + columnsArray[j].forText);
- span.id = "putValueTo" + columnsArray[j].forText;
- tn = document.createTextNode(columnsArray[j].label);
- span.appendChild(tn);
- td.appendChild(span);
- }
- else {
- span = document.createElement("span");
- span.id = "putValueTo" + columnsArray[j].forValue;
- tn = document.createTextNode(columnsArray[j].value);
- span.appendChild(tn);
- span.style.display = "none";
- td.appendChild(span);
-
- span = document.createElement("span");
- tn = document.createTextNode(columnsArray[j].label);
- span.appendChild(tn);
- td.appendChild(span);
- }
- }
- }
-
- dojo.dom.insertAtPosition(suggestTable, this.popUp, "first");
- this.handleIFrame();
-
- var suggestion = (this.data[0])[0].label;
- this.typeAhead(suggestion);
- }
-
- //handles the user pressing the 'Down Arrow' key
- org_apache_myfaces_TableSuggest.prototype.handleDownKey = function()
- {
- if(!this.firstHighlightedElem)
- {
- var firstOptionElem = this.getFirstRowElem(this.popUp);
- this.putValueToField(firstOptionElem);
- this.addHoverClass(firstOptionElem);
- this.firstHighlightedElem = firstOptionElem;
-
- this.actualHighlightedElem = firstOptionElem;
- }
- else
- {
- var nextElem = dojo.dom.nextElement(this.actualHighlightedElem);
-
- if(nextElem)
- {
- if(dojo.dom.getTagName(nextElem) == "tr")
- {
- this.putValueToField(nextElem);
- this.addOutClass(this.actualHighlightedElem);
- this.addHoverClass(nextElem);
- this.actualHighlightedElem = nextElem
- }
- }
- else
- {
- var table = dojo.html.getFirstAncestorByTag(this.actualHighlightedElem,"table");
- var pageField = dojo.dom.nextElement(table);
-
- if(pageField)
- {
- if(dojo.dom.getTagName(pageField) == "div")
- {
- this.nextPage(pageField);
- this.firstHighlightedElem = this.getFirstRowElem(this.popUp);
- this.putValueToField(this.firstHighlightedElem);
- this.addOutClass(this.actualHighlightedElem);
- this.addHoverClass(this.firstHighlightedElem);
- this.actualHighlightedElem = this.firstHighlightedElem;
- }
- }
- else
- dojo.debug("could not move to next item in table, wrong item is");dojo.debug(nextElem);
- }
- }
- }
-
-
- org_apache_myfaces_TableSuggest.prototype.nextPage = function(thisPageField)
- {
- var collLength = this.tablePagesCollection.count;
-
- if (collLength && collLength > 0)
- {
- var nextPage = this.tablePagesCollection.item(0);
- var nextPageField = this.tablePagesCollection.item(1);
-
- this.tablePagesCollection.removeAt(0);
- this.tablePagesCollection.removeAt(0);
-
- var thisPage = dojo.dom.prevElement(thisPageField);
-
- dojo.dom.removeChildren(this.popUp);
-
- dojo.dom.insertAtPosition(nextPage, this.popUp, "first");
- dojo.dom.insertAtPosition(nextPageField, this.popUp, "last");
-
- this.tablePagesCollection.add(thisPage);
- this.tablePagesCollection.add(thisPageField);
-
- this.handleIFrame();
- }
- };
-
- org_apache_myfaces_TableSuggest.prototype.previousPage = function(thisPage)
- {
- var collLength = this.tablePagesCollection.count;
-
- if (collLength && collLength > 0)
- {
- var prevPageField = this.tablePagesCollection.item(collLength - 1);
- var prevPage = this.tablePagesCollection.item(collLength - 2);
-
- this.tablePagesCollection.removeAt(collLength - 1);
- this.tablePagesCollection.removeAt(collLength - 2);
-
- var thisPageField = dojo.dom.nextElement(thisPage);
- this.tablePagesCollection.insert(0, thisPageField);
- this.tablePagesCollection.insert(0, thisPage);
-
- dojo.dom.removeChildren(this.popUp);
- dojo.dom.insertAtPosition(prevPage, this.popUp, "first");
- dojo.dom.insertAtPosition(prevPageField, this.popUp, "last");
-
- this.handleIFrame();
- }
- };
-
- org_apache_myfaces_TableSuggest.prototype.getFirstRowElem = function()
- {
- var table = dojo.dom.firstElement(this.popUp);
- if (table) {
- var tbody = table.childNodes[1];
- var firstRowElem = dojo.dom.firstElement(tbody);
- return firstRowElem;
- } else return null;
- };
-
- org_apache_myfaces_TableSuggest.prototype.getLastRowElem = function()
- {
- var table = dojo.dom.firstElement(this.popUp);
- if(table) {
- var tbody = table.childNodes[1];
- var lastRowElem = dojo.dom.lastElement(tbody);
- return lastRowElem;
- } else return null;
- };
-
- org_apache_myfaces_TableSuggest.prototype.addHoverClass = function(elem)
- {
- dojo.html.removeClass(elem, this.columnOutClass);
- dojo.html.addClass(elem, this.columnHoverClass);
- };
-
- org_apache_myfaces_TableSuggest.prototype.addOutClass = function(elem)
- {
- dojo.html.removeClass(elem, this.columnHoverClass);
- dojo.html.addClass(elem, this.columnOutClass);
- };
-
- org_apache_myfaces_TableSuggest.prototype.requestBetweenKeyUpEvents = function(millisBetweenKeyPress)
- {
- var currentTime = new Date();
-
- if( (currentTime - this.lastKeyPressTime) > millisBetweenKeyPress)
- {
- dojo.debug(currentTime - this.lastKeyPressTime);
- this.lastKeyPressTime = currentTime;
- return true;
- }
- else
- {
- dojo.debug(currentTime - this.lastKeyPressTime);
- this.lastKeyPressTime = currentTime;
- return false;
- }
- };
-
- org_apache_myfaces_TableSuggest.prototype.handleIFrame = function()
- {
- if (dojo.render.html.ie)
- {
- if (!this.iframe)
- {
- this.iframe = document.createElement("<iframe>");
- this.iframe.frameborder = '0';
- this.iframe.src = 'about:blank';
- var s = this.iframe.style;
- s.position = "absolute";
- s.zIndex = 2;
- var popUpParent = this.popUp.parentNode;
- dojo.dom.insertAtPosition(this.iframe, popUpParent, "first");
- }
-
- var popUpStyleHeight = this.popUp.style.height;
- var popUpHeight = dojo.style.getOuterHeight(this.popUp);
- var popUpContentHeight = dojo.style.getOuterHeight(this.popUp.childNodes[0]);
- var popUpContentWidth = dojo.style.getOuterWidth(this.popUp.childNodes[0]);
-
- if(popUpStyleHeight == "" || popUpHeight < popUpContentHeight)
- this.iframe.style.height = popUpHeight;
- else
- this.iframe.style.height = popUpContentHeight;
-
- if(popUpStyleHeight != "" && popUpContentHeight > popUpHeight)
- this.iframe.style.width = popUpContentWidth+13;
- else
- this.iframe.style.width = popUpContentWidth;
- }
- };
-
- org_apache_myfaces_TableSuggest.prototype.lastKeyUpEvent = function()
- {
- //dojo.lang.setTimeout('',4000);
- var currentTime = new Date();
- dojo.debug("last keyUpEvent?");
- dojo.debug(currentTime - this.lastKeyPressTime);
- if( (currentTime - this.lastKeyPressTime) > 250)
- {
- dojo.debug("was last keyUpEvent");
- return true;
- }
- else return false;
- };
-
- org_apache_myfaces_TableSuggest.prototype.resetSettings = function()
- {
- if(this.popUp)
- {
- dojo.dom.removeChildren(this.popUp);
- this.popUp.style.cssText = "";
- }
-
- if(this.iframe && this.popUp)
- this.popUp.parentNode.removeChild(this.popUp.parentNode.childNodes[0])
-
- this.firstHighlightedElem = null;
- this.actualHighlightedElem = null;
- this.iframe = null;
- this.requestLocker = false;
- this.scrollingRow = 0;
- };
-
- org_apache_myfaces_TableSuggest.prototype.onFocus = function() {
- this.hasFocus = true;
- if (this.saveOldValues)
- {
- this.oldValues = new Object();
- for (var i = 0; i < this.fieldNames.length; i++)
- {
- var fieldName = this.fieldNames[i];
- var field = dojo.byId(fieldName);
- this.oldValues[fieldName] = field.value;
- }
- this.saveOldValues = false;
- }
- }
-
- org_apache_myfaces_TableSuggest.prototype.onBlur = function() {
-
- var tableSuggest = this;
- this.hasFocus = false;
-
- var selectedRecord = null;
-
- //the timeout function will validate the user's input
- this.blurTimer = setTimeout(function() {
-
- tableSuggest.resetSettings();
- if (tableSuggest.hasFocus) return;
-
- //next time you tab into this field, you must save the old values
- tableSuggest.saveOldValues = true;
-
- var inputValue = tableSuggest.inputField.value;
-
- if (tableSuggest.data == null) return;
- //search if this value is from the list of acceptable values
- for (var i = 0; i < tableSuggest.data.length; i++)
- {
- var item = tableSuggest.data[i];
- var primaryColumn = item[0];
- if (inputValue == primaryColumn.label)
- {
- tableSuggest.updateForeignKeyFields(item);
- return;
- }
- }
- //validation failed : restore the original values of all the fields (including foreign-key fields)
- for (var i = 0; i < tableSuggest.fieldNames.length; i++)
- {
- var fieldName = tableSuggest.fieldNames[i];
- var field = dojo.byId(fieldName);
- field.value = tableSuggest.oldValues[fieldName];
- //tableSuggest.inputField.value = "";
- //tableSuggest.inputField.focus();
- }
-
- }, 500);
-
- }
-
- org_apache_myfaces_TableSuggest.prototype.updateForeignKeyFields = function(row)
- {
- for (var i = 0; i < row.length; i++)
- {
- var column = row[i];
- var fieldId, field;
-
- if (typeof column.forText != "undefined")
- {
- fieldId = column.forText;
- field = dojo.byId(fieldId);
- field.value = column.label;
- }
- else {
- fieldId = column.forValue;
- field = dojo.byId(fieldId);
- field.value = column.value;
- }
- }
- }
-
- org_apache_myfaces_TableSuggest.prototype.handleKeyDown = function(evt)
- {
- var keyCode = evt.keyCode;
-
- switch (keyCode)
- {
- case 40: //down key
- this.handleDownKey();
- break;
- case 38: //up key
- this.handleUpKey();
- break;
- case 27: //escape
- this.resetSettings();
- break;
- case 13: //enter
- this.resetSettings();
- break;
- default:
- return true;
- }
- evt.preventDefault();
- }
-
- org_apache_myfaces_TableSuggest.prototype.decideRequest = function(event)
- {
- this.inputFieldId = event.target.id;
- this.inputField = dojo.byId(this.inputFieldId);
- this.popUp = dojo.byId(event.target.id + "_auto_complete");
-
- var inputValue = this.inputField.value;
-
- if( (event.keyCode == 13) || (event.keyCode == 9) ) //enter, tab keys
- {
- this.resetSettings();
- return;
- }
-
- if(inputValue == "" )
- {
- this.resetSettings();
- return;
- }
-
- if (this.startChars) //minimum # of characters required before look-up is activated
- {
- if (inputValue.length < this.startChars)
- {
- this.resetSettings();
- return;
- }
- }
-
- //I tried to block these events in the keydown event-handler itself, but
- //haven't quite figured out how to do it.
- switch (event.keyCode)
- {
- case 40: //down key
- case 38: //up key
- case 27: //escape
- case 13: //enter
- return;
- }
-
- this.handleRequestResponse(this);
-
- };
-
+/**
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+org_apache_myfaces_TableSuggest = function(ajaxUrl,
+ millisBetweenKeyUps,
+ startChars,
+ charset,
+ acceptValueToField,
+ fieldNames,
+ styleClassOptions)
+{
+ this.tablePagesCollection = new dojo.collections.ArrayList();
+
+ this.inputField = null;
+
+ this.inputFieldId = null;
+ this.popUp = null;
+ this.url = ajaxUrl;
+ this.charset = charset;
+ this.firstHighlightedElem = null;
+ this.actualHighlightedElem = null;
+
+ this.blurTimer = null;
+ this.validateInput = true;
+ this.saveOldValues = true;
+ this.oldValues = null;
+
+ this.iframe = null;
+ this.timeOut = null;
+
+ this.data = null;
+ this.columnHeaders = null;
+
+ this.startChars = startChars;
+ this.acceptValueToField = acceptValueToField;
+ this.lastKeyPressTime = new Date();
+ this.millisBetweenKeyUps = millisBetweenKeyUps;
+ this.scrollingRow = 0;
+ this.fieldNames = fieldNames;
+
+
+ this.tableStyleClass = styleClassOptions.tableStyleClass;
+ this.columnHoverClass = styleClassOptions.columnHoverClass;
+ this.columnOutClass = styleClassOptions.columnOutClass;
+
+
+ //puting the values from the choosen row into the fields
+ org_apache_myfaces_TableSuggest.prototype.putValueToField = function(trElem)
+ {
+ if (trElem)
+ {
+ this.scrollOverflowDiv(trElem);
+
+ for (j = 0; j < trElem.childNodes.length; j++)
+ {
+ var tdElem = trElem.childNodes[j];
+
+ for (a = 0; a < tdElem.childNodes.length; a++)
+ {
+ var spanElem = tdElem.childNodes[a];
+
+ if (spanElem.id)
+ {
+ var idToPutValue = spanElem.id.substr(10);
+ var elemToPutValue = dojo.byId(idToPutValue);
+
+ if (elemToPutValue)
+ {
+ if (dojo.dom.getTagName(elemToPutValue) == "input")
+ {
+ elemToPutValue.value = spanElem.innerHTML;
+ if (elemToPutValue.onchange)
+ {
+ elemToPutValue.onchange();
+ }
+ }
+ else if (dojo.dom.getTagName(elemToPutValue) == "select")
+ {
+ for (i = 0; i < elemToPutValue.options.length; i++)
+ {
+ var optionValue = spanElem.innerHTML;
+
+ if (elemToPutValue.options[i].value == optionValue)
+ elemToPutValue.options[i].selected = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ this.inputField.focus();
+ };
+
+
+ org_apache_myfaces_TableSuggest.prototype.typeAhead = function(suggestion)
+ {
+ var len = this.inputField.value.length;
+ this.inputField.value = suggestion;
+
+ if (this.inputField.createTextRange)
+ {
+ var range = this.inputField.createTextRange();
+ range.moveStart("character", len);
+ range.moveEnd("character", suggestion.length - len);
+ range.select();
+ }
+ else if (this.inputField.setSelectionRange) {
+ this.inputField.setSelectionRange(len, suggestion.length);
+ }
+ }
+
+ org_apache_myfaces_TableSuggest.prototype.scrollOverflowDiv = function(trElem)
+ {
+ if(this.popUp.style.overflow == "auto")
+ {
+ var popUpStyleHeight = this.popUp.style.height;
+ var popUpHeight = dojo.style.getOuterHeight(this.popUp);
+ var popUpContentHeight = dojo.style.getOuterHeight(this.popUp.childNodes[0]);
+
+ if(popUpStyleHeight != "" && popUpContentHeight > popUpHeight)
+ {
+ var prevElem = dojo.dom.prevElement(trElem);
+
+ if (prevElem)
+ {
+ this.scrollingRow++;
+
+ if (this.scrollingRow >= 4)
+ {
+ var prevYPos = dojo.html.getScrollTop();
+ window.location.href = "#" + prevElem.id;
+ var currentYPos = dojo.html.getScrollTop();
+ //smoothScroll(prevYPos, currentYPos);
+ this.inputField.focus();
+ }
+ }
+ }
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.smoothYScroll = function(prevYPos,currentYPos)
+ {
+ var yDiff = prevYPos-currentYPos;
+
+ while(yDiff < 0){
+ window.scrollBy(0,-50);
+ dojo.lang.setTimeout('org_apache_myfaces_TableSuggest.prototype.smoothYScroll('+prevYPos+','+currentYPos+')',1000);
+ yDiff = yDiff+50;
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.handleRequestResponse = function(tableSuggest)
+ {
+
+ if (this.timeOut != null)
+ {
+ clearTimeout(this.timeOut);
+ this.timeOut = null;
+ }
+
+ var idValuePair = "&" + this.inputField.id + "=" + this.inputField.value;
+
+ this.timeOut = setTimeout(function() {
+
+ this.firstHighlightedElem = null;
+ this.actualHighlightedElem = null;
+
+ dojo.io.bind(
+ {
+ url: tableSuggest.url + idValuePair,
+ handle: function(type, data, evt) {
+
+ dojo.debug("after response");
+ //if(data) dojo.debug(data);
+
+ if(type == "load" && data)
+ {
+ tableSuggest.parseAjaxResponse(data);
+ tableSuggest.renderDropdown();
+ return;
+
+ dojo.debug("response successful");
+ var tablePagesArray = dojo.html.createNodesFromText(data);
+ var collection = tableSuggest.tablePagesCollection;
+
+ var firstPage = null;
+ var firstPageField = null;
+
+ dojo.dom.removeChildren(tableSuggest.popUp);
+
+ collection.clear();
+
+ for(k=0;k<tablePagesArray.length;k++)
+ {
+ if(k==0)
+ {
+ firstPage = tablePagesArray[k];
+ firstPageField = tablePagesArray[k+1];
+ dojo.dom.insertAtPosition(firstPage, tableSuggest.popUp, "first");
+ dojo.dom.insertAtPosition(firstPageField, tableSuggest.popUp, "last");
+ k++;
+
+ if(firstPage.rows && firstPage.rows.length == 2)
+ {
+ var row = firstPage.rows[1];
+ tableSuggest.putValueToField(row);
+ }
+ }
+ else
+ {
+ collection.add(tablePagesArray[k]);
+ }
+ }
+
+ tableSuggest.handleIFrame();
+ }
+ else if(type == "error")
+ {
+ dojo.debug("error during response");
+ //dojo.debug(data);
+ // here, data is our error object
+ }
+ }, //end function
+ mimetype: "text/xml",
+ content: { charset: tableSuggest.charset }
+ }); //end bind
+
+ }, this.millisBetweenKeyUps);
+ };
+
+ //handles the user pressing the 'Up-Arrow' key
+ org_apache_myfaces_TableSuggest.prototype.handleUpKey = function()
+ {
+ var prevElem = dojo.dom.prevElement(this.actualHighlightedElem);
+
+ if(prevElem)
+ {
+ if(dojo.dom.getTagName(prevElem) == "tr")
+ {
+ this.putValueToField(prevElem);
+ this.addOutClass(this.actualHighlightedElem);
+ this.addHoverClass(prevElem);
+ this.actualHighlightedElem = prevElem;
+ }
+ }
+ else
+ {
+ var table = dojo.html.getFirstAncestorByTag(this.actualHighlightedElem,"table");
+
+ if(table)
+ {
+ this.previousPage(table);
+ this.addOutClass(this.actualHighlightedElem);
+ this.actualHighlightedElem = this.getLastRowElem(this.popUp);
+ this.putValueToField(this.actualHighlightedElem);
+ this.addHoverClass(this.actualHighlightedElem);
+ }
+ else
+ dojo.debug("could not move to next item in table, wrong item is");dojo.debug(nextElem);
+ }
+ }
+ }
+
+ //parses the XML ajax response data
+ org_apache_myfaces_TableSuggest.prototype.parseAjaxResponse = function(data)
+ {
+ var root = data.documentElement;
+
+ //parse the column names of the table to be rendered
+ var columnHeaders = root.getElementsByTagName("columnHeader");
+ var columnHeadersArray = new Array();
+ for (var i = 0; i < columnHeaders.length; i++)
+ {
+ columnHeadersArray[i] = columnHeaders[i].firstChild.nodeValue;
+ }
+ this.columnHeaders = columnHeadersArray;
+
+ //parse the individual data items
+ var items = root.getElementsByTagName("item");
+ var itemsArray = new Array();
+
+ for (var i = 0; i < items.length; i++)
+ {
+ var currentItem = items[i];
+ var columnsArray = new Array();
+
+ for (var j = 0; j < currentItem.childNodes.length; j++)
+ {
+ var currentColumn = currentItem.childNodes[j];
+ var column = new Object();
+
+ var currentChild = currentColumn.firstChild;
+
+ do {
+ column[currentChild.tagName] = currentChild.firstChild.nodeValue;
+ } while (currentChild = currentChild.nextSibling);
+
+ columnsArray[j] = column;
+ }
+
+ itemsArray[i] = columnsArray;
+ }
+ this.data = itemsArray;
+ }
+
+ //Render the ajax drop-down window
+ org_apache_myfaces_TableSuggest.prototype.renderDropdown = function()
+ {
+ dojo.dom.removeChildren(this.popUp);
+
+ //if no data exists
+ if (this.data == null || this.data.length == 0)
+ {
+ this.resetSettings();
+ return;
+ }
+
+ //create a table for the suggesting items
+ var suggestTable = document.createElement("table");
+ //suggestTable.setAttribute("class", this.tableStyleClass);
+ suggestTable.className = "ajaxTable";
+
+ var tbody = document.createElement("tbody");
+ suggestTable.appendChild(tbody);
+
+ var thead = suggestTable.createTHead();
+ var tr, td, tn, span;
+
+ //add the column Headers
+ tr = thead.insertRow(0);
+
+ for (var i = 0; i < this.columnHeaders.length; i++)
+ {
+ td = tr.insertCell(tr.cells.length);
+ tn = document.createTextNode(this.columnHeaders[i]);
+ td.appendChild(tn);
+ }
+
+ var tableSuggestAjax = this;
+
+ //adding the data items
+ for (var i = 0; i < this.data.length; i++)
+ {
+ var columnsArray = this.data[i];
+ tr = tbody.insertRow(tbody.rows.length);
+
+ tr.onmouseover = function() { this.className = tableSuggestAjax.columnHoverClass; }
+ tr.onmouseout = function() { this.className= tableSuggestAjax.columnOutClass; }
+ tr.id = "row" + (i + 1) + this.inputFieldId;
+ var tableSuggest = this;
+ tr.onclick = function(event) {
+ var evt = (event) ? event : window.event;
+
+ //find the enclosing tr element
+ var target = evt.target || evt.srcElement;
+ var obj = target.parentNode;
+ while (obj.tagName != 'TR')
+ {
+ obj = obj.parentNode;
+ }
+
+ tableSuggest.putValueToField(obj);
+ }
+
+ for (var j = 0; j < columnsArray.length; j++)
+ {
+ td = tr.insertCell(tr.cells.length);
+
+ //DEBUG
+ if (typeof columnsArray[j].forText != "undefined")
+ {
+ span = document.createElement("span");
+ //span.setAttribute("id", "putValueTo" + columnsArray[j].forText);
+ span.id = "putValueTo" + columnsArray[j].forText;
+ tn = document.createTextNode(columnsArray[j].label);
+ span.appendChild(tn);
+ td.appendChild(span);
+ }
+ else {
+ span = document.createElement("span");
+ span.id = "putValueTo" + columnsArray[j].forValue;
+ tn = document.createTextNode(columnsArray[j].value);
+ span.appendChild(tn);
+ span.style.display = "none";
+ td.appendChild(span);
+
+ span = document.createElement("span");
+ tn = document.createTextNode(columnsArray[j].label);
+ span.appendChild(tn);
+ td.appendChild(span);
+ }
+ }
+ }
+
+ dojo.dom.insertAtPosition(suggestTable, this.popUp, "first");
+ this.handleIFrame();
+
+ var suggestion = (this.data[0])[0].label;
+ this.typeAhead(suggestion);
+ }
+
+ //handles the user pressing the 'Down Arrow' key
+ org_apache_myfaces_TableSuggest.prototype.handleDownKey = function()
+ {
+ if(!this.firstHighlightedElem)
+ {
+ var firstOptionElem = this.getFirstRowElem(this.popUp);
+ this.putValueToField(firstOptionElem);
+ this.addHoverClass(firstOptionElem);
+ this.firstHighlightedElem = firstOptionElem;
+
+ this.actualHighlightedElem = firstOptionElem;
+ }
+ else
+ {
+ var nextElem = dojo.dom.nextElement(this.actualHighlightedElem);
+
+ if(nextElem)
+ {
+ if(dojo.dom.getTagName(nextElem) == "tr")
+ {
+ this.putValueToField(nextElem);
+ this.addOutClass(this.actualHighlightedElem);
+ this.addHoverClass(nextElem);
+ this.actualHighlightedElem = nextElem
+ }
+ }
+ else
+ {
+ var table = dojo.html.getFirstAncestorByTag(this.actualHighlightedElem,"table");
+ var pageField = dojo.dom.nextElement(table);
+
+ if(pageField)
+ {
+ if(dojo.dom.getTagName(pageField) == "div")
+ {
+ this.nextPage(pageField);
+ this.firstHighlightedElem = this.getFirstRowElem(this.popUp);
+ this.putValueToField(this.firstHighlightedElem);
+ this.addOutClass(this.actualHighlightedElem);
+ this.addHoverClass(this.firstHighlightedElem);
+ this.actualHighlightedElem = this.firstHighlightedElem;
+ }
+ }
+ else
+ dojo.debug("could not move to next item in table, wrong item is");dojo.debug(nextElem);
+ }
+ }
+ }
+
+
+ org_apache_myfaces_TableSuggest.prototype.nextPage = function(thisPageField)
+ {
+ var collLength = this.tablePagesCollection.count;
+
+ if (collLength && collLength > 0)
+ {
+ var nextPage = this.tablePagesCollection.item(0);
+ var nextPageField = this.tablePagesCollection.item(1);
+
+ this.tablePagesCollection.removeAt(0);
+ this.tablePagesCollection.removeAt(0);
+
+ var thisPage = dojo.dom.prevElement(thisPageField);
+
+ dojo.dom.removeChildren(this.popUp);
+
+ dojo.dom.insertAtPosition(nextPage, this.popUp, "first");
+ dojo.dom.insertAtPosition(nextPageField, this.popUp, "last");
+
+ this.tablePagesCollection.add(thisPage);
+ this.tablePagesCollection.add(thisPageField);
+
+ this.handleIFrame();
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.previousPage = function(thisPage)
+ {
+ var collLength = this.tablePagesCollection.count;
+
+ if (collLength && collLength > 0)
+ {
+ var prevPageField = this.tablePagesCollection.item(collLength - 1);
+ var prevPage = this.tablePagesCollection.item(collLength - 2);
+
+ this.tablePagesCollection.removeAt(collLength - 1);
+ this.tablePagesCollection.removeAt(collLength - 2);
+
+ var thisPageField = dojo.dom.nextElement(thisPage);
+ this.tablePagesCollection.insert(0, thisPageField);
+ this.tablePagesCollection.insert(0, thisPage);
+
+ dojo.dom.removeChildren(this.popUp);
+ dojo.dom.insertAtPosition(prevPage, this.popUp, "first");
+ dojo.dom.insertAtPosition(prevPageField, this.popUp, "last");
+
+ this.handleIFrame();
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.getFirstRowElem = function()
+ {
+ var table = dojo.dom.firstElement(this.popUp);
+ if (table) {
+ var tbody = table.childNodes[1];
+ var firstRowElem = dojo.dom.firstElement(tbody);
+ return firstRowElem;
+ } else return null;
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.getLastRowElem = function()
+ {
+ var table = dojo.dom.firstElement(this.popUp);
+ if(table) {
+ var tbody = table.childNodes[1];
+ var lastRowElem = dojo.dom.lastElement(tbody);
+ return lastRowElem;
+ } else return null;
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.addHoverClass = function(elem)
+ {
+ dojo.html.removeClass(elem, this.columnOutClass);
+ dojo.html.addClass(elem, this.columnHoverClass);
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.addOutClass = function(elem)
+ {
+ dojo.html.removeClass(elem, this.columnHoverClass);
+ dojo.html.addClass(elem, this.columnOutClass);
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.requestBetweenKeyUpEvents = function(millisBetweenKeyPress)
+ {
+ var currentTime = new Date();
+
+ if( (currentTime - this.lastKeyPressTime) > millisBetweenKeyPress)
+ {
+ dojo.debug(currentTime - this.lastKeyPressTime);
+ this.lastKeyPressTime = currentTime;
+ return true;
+ }
+ else
+ {
+ dojo.debug(currentTime - this.lastKeyPressTime);
+ this.lastKeyPressTime = currentTime;
+ return false;
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.handleIFrame = function()
+ {
+ if (dojo.render.html.ie)
+ {
+ if (!this.iframe)
+ {
+ this.iframe = document.createElement("<iframe>");
+ this.iframe.frameborder = '0';
+ this.iframe.src = 'about:blank';
+ var s = this.iframe.style;
+ s.position = "absolute";
+ s.zIndex = 2;
+ var popUpParent = this.popUp.parentNode;
+ dojo.dom.insertAtPosition(this.iframe, popUpParent, "first");
+ }
+
+ var popUpStyleHeight = this.popUp.style.height;
+ var popUpHeight = dojo.style.getOuterHeight(this.popUp);
+ var popUpContentHeight = dojo.style.getOuterHeight(this.popUp.childNodes[0]);
+ var popUpContentWidth = dojo.style.getOuterWidth(this.popUp.childNodes[0]);
+
+ if(popUpStyleHeight == "" || popUpHeight < popUpContentHeight)
+ this.iframe.style.height = popUpHeight;
+ else
+ this.iframe.style.height = popUpContentHeight;
+
+ if(popUpStyleHeight != "" && popUpContentHeight > popUpHeight)
+ this.iframe.style.width = popUpContentWidth+13;
+ else
+ this.iframe.style.width = popUpContentWidth;
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.lastKeyUpEvent = function()
+ {
+ //dojo.lang.setTimeout('',4000);
+ var currentTime = new Date();
+ dojo.debug("last keyUpEvent?");
+ dojo.debug(currentTime - this.lastKeyPressTime);
+ if( (currentTime - this.lastKeyPressTime) > 250)
+ {
+ dojo.debug("was last keyUpEvent");
+ return true;
+ }
+ else return false;
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.resetSettings = function()
+ {
+ if(this.popUp)
+ {
+ dojo.dom.removeChildren(this.popUp);
+ this.popUp.style.cssText = "";
+ }
+
+ if(this.iframe && this.popUp)
+ this.popUp.parentNode.removeChild(this.popUp.parentNode.childNodes[0])
+
+ this.firstHighlightedElem = null;
+ this.actualHighlightedElem = null;
+ this.iframe = null;
+ this.requestLocker = false;
+ this.scrollingRow = 0;
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.onFocus = function() {
+ this.hasFocus = true;
+ if (this.saveOldValues)
+ {
+ this.oldValues = new Object();
+ for (var i = 0; i < this.fieldNames.length; i++)
+ {
+ var fieldName = this.fieldNames[i];
+ var field = dojo.byId(fieldName);
+ this.oldValues[fieldName] = field.value;
+ }
+ this.saveOldValues = false;
+ }
+ }
+
+ org_apache_myfaces_TableSuggest.prototype.onBlur = function() {
+
+ var tableSuggest = this;
+ this.hasFocus = false;
+
+ var selectedRecord = null;
+
+ //the timeout function will validate the user's input
+ this.blurTimer = setTimeout(function() {
+
+ tableSuggest.resetSettings();
+ if (tableSuggest.hasFocus) return;
+
+ //next time you tab into this field, you must save the old values
+ tableSuggest.saveOldValues = true;
+
+ var inputValue = tableSuggest.inputField.value;
+
+ if (tableSuggest.data == null) return;
+ //search if this value is from the list of acceptable values
+ for (var i = 0; i < tableSuggest.data.length; i++)
+ {
+ var item = tableSuggest.data[i];
+ var primaryColumn = item[0];
+ if (inputValue == primaryColumn.label)
+ {
+ tableSuggest.updateForeignKeyFields(item);
+ return;
+ }
+ }
+ //validation failed : restore the original values of all the fields (including foreign-key fields)
+ for (var i = 0; i < tableSuggest.fieldNames.length; i++)
+ {
+ var fieldName = tableSuggest.fieldNames[i];
+ var field = dojo.byId(fieldName);
+ field.value = tableSuggest.oldValues[fieldName];
+ //tableSuggest.inputField.value = "";
+ //tableSuggest.inputField.focus();
+ }
+
+ }, 500);
+
+ }
+
+ org_apache_myfaces_TableSuggest.prototype.updateForeignKeyFields = function(row)
+ {
+ for (var i = 0; i < row.length; i++)
+ {
+ var column = row[i];
+ var fieldId, field;
+
+ if (typeof column.forText != "undefined")
+ {
+ fieldId = column.forText;
+ field = dojo.byId(fieldId);
+ field.value = column.label;
+ }
+ else {
+ fieldId = column.forValue;
+ field = dojo.byId(fieldId);
+ field.value = column.value;
+ }
+ }
+ }
+
+ org_apache_myfaces_TableSuggest.prototype.handleKeyDown = function(evt)
+ {
+ var keyCode = evt.keyCode;
+
+ switch (keyCode)
+ {
+ case 40: //down key
+ this.handleDownKey();
+ break;
+ case 38: //up key
+ this.handleUpKey();
+ break;
+ case 27: //escape
+ this.resetSettings();
+ break;
+ case 13: //enter
+ this.resetSettings();
+ break;
+ default:
+ return true;
+ }
+ evt.preventDefault();
+ }
+
+ org_apache_myfaces_TableSuggest.prototype.decideRequest = function(event)
+ {
+ this.inputFieldId = event.target.id;
+ this.inputField = dojo.byId(this.inputFieldId);
+ this.popUp = dojo.byId(event.target.id + "_auto_complete");
+
+ var inputValue = this.inputField.value;
+
+ if( (event.keyCode == 13) || (event.keyCode == 9) ) //enter, tab keys
+ {
+ this.resetSettings();
+ return;
+ }
+
+ if(inputValue == "" )
+ {
+ this.resetSettings();
+ return;
+ }
+
+ if (this.startChars) //minimum # of characters required before look-up is activated
+ {
+ if (inputValue.length < this.startChars)
+ {
+ this.resetSettings();
+ return;
+ }
+ }
+
+ //I tried to block these events in the keydown event-handler itself, but
+ //haven't quite figured out how to do it.
+ switch (event.keyCode)
+ {
+ case 40: //down key
+ case 38: //up key
+ case 27: //escape
+ case 13: //enter
+ return;
+ }
+
+ this.handleRequestResponse(this);
+
+ };
+
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/timednotifier/resource/timednotifier.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/timednotifier/resource/timednotifier.js?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/timednotifier/resource/timednotifier.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/timednotifier/resource/timednotifier.js Tue Aug 1 10:43:28 2006
@@ -1,61 +1,61 @@
-/**
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-/*=====================================================
-* A timed notifier encapsulation class
-* @author werpu
-* this class will enable a timed notfier
-* system within myfaces
-======================================================*/
-myfaces_TimedNotifier = function (dialogId, confirmButtonId, timeShow, timeHide) {
- dojo.widget.HtmlWidget.call(this);
- this.dialogId = dialogId;
- /*
- * notification message timeouts
- */
- this.timeoutShow = timeShow;
- this.timeoutHide = timeHide;
- /*if not set, set default values*/
- if (this.timeoutShow == null) {
- this.timeoutShow = 0;
- }
- if (this.timeoutHide == null) {
- this.timeoutHide = -1;
- }
- this.dialog = dojo.widget.createWidget("Dialog", {id:(this.dialogId + "_internaldialogid"), bgColor:"white", bgOpacity:0.5, toggle:"fade", toggleDuration:250}, dojo.byId(this.dialogId));
-
- if(confirmButtonId != null)
- dojo.event.connect(confirmButtonId, "onclick", this, "hideDialog");
-
- /*
- * timing functions for show and hide
- /*shows the dialog under the given circumstances*/
- this.showDialog = function () {
- this.dialog.show();
- if (this.timeoutHide > 0) {
- dojo.lang.setTimeout(this, this.hideDialog, this.timeoutHide);
- }
- };
- /*
- * simple hide function
- */
- this.hideDialog = function () {
- this.dialog.hide();
- };
-};
-
+/**
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+/*=====================================================
+* A timed notifier encapsulation class
+* @author werpu
+* this class will enable a timed notfier
+* system within myfaces
+======================================================*/
+myfaces_TimedNotifier = function (dialogId, confirmButtonId, timeShow, timeHide) {
+ dojo.widget.HtmlWidget.call(this);
+ this.dialogId = dialogId;
+ /*
+ * notification message timeouts
+ */
+ this.timeoutShow = timeShow;
+ this.timeoutHide = timeHide;
+ /*if not set, set default values*/
+ if (this.timeoutShow == null) {
+ this.timeoutShow = 0;
+ }
+ if (this.timeoutHide == null) {
+ this.timeoutHide = -1;
+ }
+ this.dialog = dojo.widget.createWidget("Dialog", {id:(this.dialogId + "_internaldialogid"), bgColor:"white", bgOpacity:0.5, toggle:"fade", toggleDuration:250}, dojo.byId(this.dialogId));
+
+ if(confirmButtonId != null)
+ dojo.event.connect(confirmButtonId, "onclick", this, "hideDialog");
+
+ /*
+ * timing functions for show and hide
+ /*shows the dialog under the given circumstances*/
+ this.showDialog = function () {
+ this.dialog.show();
+ if (this.timeoutHide > 0) {
+ dojo.lang.setTimeout(this, this.hideDialog, this.timeoutHide);
+ }
+ };
+ /*
+ * simple hide function
+ */
+ this.hideDialog = function () {
+ this.dialog.hide();
+ };
+};
+
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/timednotifier/resource/timednotifier.js
------------------------------------------------------------------------------
svn:eol-style = native