Skip to content
Browse files

https://issues.apache.org/jira/browse/MYFACES-3653 making the preserv…

…e focus code optional

git-svn-id: https://svn.apache.org/repos/asf/myfaces/core/trunk@1412932 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 8c15e2f commit 760b53edcebac551f8fc091bd9f54f49c64f9f01 @weblets weblets committed Nov 23, 2012
View
9 api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
@@ -572,6 +572,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
},
setCaretPosition:function (ctrl, pos) {
+
if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
@@ -593,8 +594,12 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
*
* @param item the item to be replaced
* @param markup the markup for the replacement
+ * @param preserveFocus, tries to preserve the focus within the outerhtml operation
+ * if set to true a focus preservation algorithm based on document.activeElement is
+ * used to preserve the focus at the exactly same location as it was
+ *
*/
- outerHTML : function(item, markup) {
+ outerHTML : function(item, markup, preserveFocus) {
this._assertStdParams(item, markup, "outerHTML");
// we can work on a single element in a cross browser fashion
// regarding the focus thanks to the
@@ -610,7 +615,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
var focusElementId = null;
var caretPosition = 0;
- if ('undefined' != typeof document.activeElement) {
+ if (preserveFocus && 'undefined' != typeof document.activeElement) {
focusElementId = (document.activeElement) ? document.activeElement.id : null;
caretPosition = this.getCaretPosition(document.activeElement);
}
View
2 api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
@@ -605,7 +605,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
if (!item) {
throw this._raiseError(new Error(), _Lang.getMessage("ERR_ITEM_ID_NOTFOUND", null, "_AjaxResponse.replaceHtmlItem", (itemIdToReplace) ? itemIdToReplace.toString() : "undefined"),"replaceHtmlItem");
}
- return _Dom.outerHTML(item, markup);
+ return _Dom.outerHTML(item, markup, this._RT.getLocalOrGlobalConfig(context, "preserveFocus", false));
},
/**

0 comments on commit 760b53e

Please sign in to comment.
Something went wrong with that request. Please try again.