You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/10/18 02:17:10 UTC
[7/9] git commit: Remove field focus tracking support
Remove field focus tracking support
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/c1c7aee6
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/c1c7aee6
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/c1c7aee6
Branch: refs/heads/5.4-js-rewrite
Commit: c1c7aee649c2e0fc13db204514ff7362a38918cc
Parents: 8eb9807
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Wed Oct 17 10:40:12 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed Oct 17 10:40:12 2012 -0700
----------------------------------------------------------------------
.../tapestry5/corelib/components/datefield.js | 78 +++++++--------
.../resources/org/apache/tapestry5/tapestry.js | 48 +---------
2 files changed, 40 insertions(+), 86 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c1c7aee6/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js b/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js
index 4bc6292..acd6e21 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js
@@ -16,7 +16,7 @@ Tapestry.DateField = Class.create({
// Initializes a DateField from a JSON specification.
- initialize : function(spec) {
+ initialize: function (spec) {
this.field = $(spec.field);
this.trigger = $(spec.field + "-trigger");
this.parseURL = spec.parseURL;
@@ -27,7 +27,7 @@ Tapestry.DateField = Class.create({
this.popup = null;
},
- triggerClicked : function() {
+ triggerClicked: function () {
if (this.field.disabled)
return;
@@ -53,7 +53,7 @@ Tapestry.DateField = Class.create({
return;
}
- var resultHandler = function(result) {
+ var resultHandler = function (result) {
var date = new Date();
date.setTime(result);
@@ -65,17 +65,17 @@ Tapestry.DateField = Class.create({
this.revealPopup();
};
- var errorHandler = function(message) {
+ var errorHandler = function (message) {
this.field.showValidationMessage(message.escapeHTML());
this.field.activate();
};
this.sendServerRequest(this.parseURL, value, resultHandler,
- errorHandler);
+ errorHandler);
},
- sendServerRequest : function(url, input, resultHandler, errorHandler) {
- var successHandler = function(response) {
+ sendServerRequest: function (url, input, resultHandler, errorHandler) {
+ var successHandler = function (response) {
var json = response.responseJSON;
var result = json.result;
@@ -89,15 +89,15 @@ Tapestry.DateField = Class.create({
}.bind(this);
Tapestry.ajaxRequest(url, {
- method : 'get',
- parameters : {
- input : input
+ method: 'get',
+ parameters: {
+ input: input
},
- onSuccess : successHandler
+ onSuccess: successHandler
});
},
- createPopup : function() {
+ createPopup: function () {
this.datePicker = new DatePicker();
this.datePicker.setFirstWeekDay(this.firstDay);
@@ -105,29 +105,27 @@ Tapestry.DateField = Class.create({
this.popup = $(this.datePicker.create());
this.field.insert({
- after : this.popup
+ after: this.popup
});
this.popup.absolutize().hide();
- this.datePicker.onselect = function() {
+ this.datePicker.onselect = function () {
var date = this.datePicker.getDate();
- var resultHandler = function(result) {
- //TAP5-1844
- if (this.field.value != result) {
- this.field.value = result;
- Tapestry.currentFocusField = this.field;
- //fire an FOCUS_CHANGE_EVENT event to force inputValidation on field
- document.fire(Tapestry.FOCUS_CHANGE_EVENT, this.field);
-
- }
- this.hidePopup();
+ var resultHandler = function (result) {
+ //TAP5-1844
+ if (this.field.value != result) {
+ this.field.value = result;
+ Tapestry.currentFocusField = this.field;
+ //fire an FOCUS_CHANGE_EVENT event to force inputValidation on field
+ document.fire(Tapestry.FOCUS_CHANGE_EVENT, this.field);
- new Effect.Highlight(this.field);
+ }
+ this.hidePopup();
};
- var errorHandler = function(message) {
+ var errorHandler = function (message) {
this.field.showValidationMessage(message.escapeHTML());
this.field.activate();
@@ -142,11 +140,11 @@ Tapestry.DateField = Class.create({
}
this.sendServerRequest(this.formatURL, date.getTime(),
- resultHandler, errorHandler);
+ resultHandler, errorHandler);
}.bind(this);
},
- positionPopup : function() {
+ positionPopup: function () {
// The field may be a hidden field, in which csae, position the popup
// based on the trigger, not
// the hidden.
@@ -154,34 +152,34 @@ Tapestry.DateField = Class.create({
var reference = this.field.type == "text" ? this.field : this.trigger;
this.popup.clonePosition(reference, {
- offsetTop : reference.getHeight() + 2
+ offsetTop: reference.getHeight() + 2
}).setStyle({
- width : "",
- height : ""
- });
+ width: "",
+ height: ""
+ });
},
/** Duration, in seconds, used when fading the popup in or out. */
- FADE_DURATION : .20,
+ FADE_DURATION: .20,
- hidePopup : function() {
+ hidePopup: function () {
new Effect.Fade(this.popup, {
- duration : this.FADE_DURATION
+ duration: this.FADE_DURATION
});
},
- revealPopup : function() {
+ revealPopup: function () {
// Only show one DateField popup at a time.
if (Tapestry.DateField.activeDateField != undefined
- && Tapestry.DateField.activeDateField != this) {
+ && Tapestry.DateField.activeDateField != this) {
Tapestry.DateField.activeDateField.hidePopup();
}
new Effect.Appear(this.popup, {
- duration : this.FADE_DURATION
+ duration: this.FADE_DURATION
});
Tapestry.DateField.activeDateField = this;
@@ -190,13 +188,13 @@ Tapestry.DateField = Class.create({
Tapestry.DateField.localized = false;
-Tapestry.DateField.initLocalization = function(localization) {
+Tapestry.DateField.initLocalization = function (localization) {
DatePicker.months = localization.months;
DatePicker.days = localization.days.toArray();
Tapestry.DateField.prototype.firstDay = localization.firstDay;
};
-Tapestry.Initializer.dateField = function(spec) {
+Tapestry.Initializer.dateField = function (spec) {
new Tapestry.DateField(spec);
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c1c7aee6/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
index 268da0f..c645387 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
@@ -67,7 +67,7 @@ define("core/compat/tapestry", [
/**
* Event, fired on the document object, which identifies the current focus
- * input element.
+ * input element. Starting in Tapestry 5.4, focus changing is not longer tracked.
*/
FOCUS_CHANGE_EVENT: "tapestry:focuschange",
@@ -106,7 +106,7 @@ define("core/compat/tapestry", [
* CSS Class added to a <form> element that directs Tapestry to
* prevent normal (HTTP POST) form submission, in favor of Ajax
* (XmlHttpRequest) submission. This is still supported in Tapestry 5.4, but
- * replaced with the data-prevent-submission attribute.
+ * replaced with the data-prevent-submission attribute. It will be removed in Tapestry 5.5.
*
* @deprecated Use data-prevent-submission="true" instead
*/
@@ -149,30 +149,6 @@ define("core/compat/tapestry", [
element.hide();
element.removeClassName("t-invisible");
});
-
- /*
- * Adds a focus observer that fades all error popups except for the
- * field in question.
- */
- $$("INPUT", "SELECT", "TEXTAREA").each(function (element) {
- /*
- * Due to Ajax, we may execute the callback multiple times, and we
- * don't want to add multiple listeners to the same element.
- */
- var t = $T(element);
-
- if (!t.observingFocusChange) {
- element.observe("focus", function () {
- if (element != Tapestry.currentFocusField) {
- document.fire(Tapestry.FOCUS_CHANGE_EVENT, element);
-
- Tapestry.currentFocusField = element;
- }
- });
-
- t.observingFocusChange = true;
- }
- });
},
/*
@@ -1064,26 +1040,6 @@ define("core/compat/tapestry", [
};
Event.observe(window, "resize", this.repositionBubble.bind(this));
-
- document.observe(Tapestry.FOCUS_CHANGE_EVENT, function (event) {
- if (this.ignoreNextFocus) {
- this.ignoreNextFocus = false;
- return;
- }
-
- if (event.memo == this.field) {
- this.fadeIn();
- return;
- }
-
- /*
- * If this field is not the focus field after a focus change, then
- * its bubble, if visible, should fade out. This covers tabbing
- * from one form to another.
- */
- this.fadeOut();
-
- }.bind(this));
},
showMessage: function (message) {