You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2013/06/12 15:45:33 UTC
git commit: WICKET-5229 simplify focus tracking with jQuery
focusin/focusout
Updated Branches:
refs/heads/master 995182631 -> 21ecfee58
WICKET-5229 simplify focus tracking with jQuery focusin/focusout
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/21ecfee5
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/21ecfee5
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/21ecfee5
Branch: refs/heads/master
Commit: 21ecfee588f9be781bf2ce4429d39a1cc2f2926e
Parents: 9951826
Author: svenmeier <sv...@meiers.net>
Authored: Wed Jun 12 15:44:48 2013 +0200
Committer: svenmeier <sv...@meiers.net>
Committed: Wed Jun 12 15:44:48 2013 +0200
----------------------------------------------------------------------
.../wicket/ajax/res/js/wicket-ajax-jquery.js | 39 ++++----------------
1 file changed, 7 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/21ecfee5/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
index 347f319..89f756f 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
@@ -959,11 +959,6 @@
this._executeHandlers(attrs.sh, attrs, null, null, 'success');
Wicket.Event.publish('/ajax/call/success', attrs, null, null, 'success');
- // re-attach the events to the new components (a bit blunt method...)
- // This should be changed for IE See comments in wicket-event.js add (attachEvent/detachEvent)
- // IE this will cause double events for everything.. (mostly because of the jQuery.proxy(element))
- Wicket.Focus.attachFocusEvent();
-
// set the focus to the last component
window.setTimeout("Wicket.Focus.requestFocus();", 0);
@@ -2424,7 +2419,7 @@
refocusLastFocusedComponentAfterResponse : false,
focusSetFromServer : false,
- setFocus: function (event) {
+ focusin: function (event) {
event = Wicket.Event.fix(event);
var target = event.target;
@@ -2435,7 +2430,7 @@
}
},
- blur: function (event) {
+ focusout: function (event) {
event = Wicket.Event.fix(event);
var target = event.target;
@@ -2545,30 +2540,6 @@
Wicket.Log.info("refocus last focused component not needed/allowed");
}
Wicket.Focus.refocusLastFocusedComponentAfterResponse = false;
- },
-
- setFocusOnElements: function (elements) {
- // we need to cache array length because IE will try to recalculate
- // the collection of elements every time length() is called which can be quiet expensive
- // if the collection is a result of getElementsByTagName or a similar function.
- var len = elements.length;
- for (var i = 0; i < len; i++)
- {
- if (elements[i].wicketFocusSet !== true)
- {
- Wicket.Event.add(elements[i], 'focus', Wicket.Focus.setFocus);
- Wicket.Event.add(elements[i], 'blur', Wicket.Focus.blur);
- elements[i].wicketFocusSet = true;
- }
- }
- },
-
- attachFocusEvent: function () {
- Wicket.Focus.setFocusOnElements(document.getElementsByTagName("input"));
- Wicket.Focus.setFocusOnElements(document.getElementsByTagName("select"));
- Wicket.Focus.setFocusOnElements(document.getElementsByTagName("textarea"));
- Wicket.Focus.setFocusOnElements(document.getElementsByTagName("button"));
- Wicket.Focus.setFocusOnElements(document.getElementsByTagName("a"));
}
}
});
@@ -2658,7 +2629,11 @@
// MISC FUNCTIONS
- Wicket.Event.add(window, 'domready', Wicket.Focus.attachFocusEvent);
+ /**
+ * Track focussed element.
+ */
+ Wicket.Event.add(window, 'focusin', Wicket.Focus.focusin);
+ Wicket.Event.add(window, 'focusout', Wicket.Focus.focusout);
/**
* Remove any scheduled timers on the removed element.