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 2011/06/21 23:53:15 UTC
svn commit: r1138206 -
/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
Author: hlship
Date: Tue Jun 21 21:53:15 2011
New Revision: 1138206
URL: http://svn.apache.org/viewvc?rev=1138206&view=rev
Log:
TAP5-1539: Optimize document scans used by Tapestry.FieldEventManager to not locate the label or icon until actually needed
Modified:
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
Modified: tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js?rev=1138206&r1=1138205&r2=1138206&view=diff
==============================================================================
--- tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js (original)
+++ tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js Tue Jun 21 21:53:15 2011
@@ -1651,13 +1651,6 @@ Tapestry.FieldEventManager = Class.creat
initialize : function(field) {
this.field = $(field);
- var id = this.field.id;
-
- var selector = "label[for='" + id + "']";
-
- this.label = this.field.up("form").down(selector);
- this.icon = $(id + '_icon');
-
this.translator = Prototype.K;
var fem = $(this.field.form).getFormEventManager();
@@ -1683,6 +1676,23 @@ Tapestry.FieldEventManager = Class.creat
}
},
+ getLabel : function() {
+ if (!this.label) {
+ var selector = "label[for='" + this.field.id + "']";
+ this.label = this.field.form.down(selector);
+ }
+
+ return this.label;
+ },
+
+ getIcon : function() {
+ if (!this.icon) {
+ this.com = $(this.field.id + "_icon");
+ }
+
+ return this.icon;
+ },
+
/**
* Removes validation decorations if present. Hides the ErrorPopup, if it
* exists.
@@ -1690,11 +1700,9 @@ Tapestry.FieldEventManager = Class.creat
removeDecorations : function() {
this.field.removeClassName("t-error");
- if (this.label)
- this.label.removeClassName("t-error");
+ this.getLabel() && this.getLabel().removeClassName("t-error");
- if (this.icon)
- this.icon.hide();
+ this.getIcon() && this.getIcon().hide();
if (this.errorPopup)
this.errorPopup.hide();
@@ -1714,12 +1722,12 @@ Tapestry.FieldEventManager = Class.creat
this.field.addClassName("t-error");
- if (this.label)
- this.label.addClassName("t-error");
+ this.getLabel() && this.getLabel().addClassName("t-error");
+
+ var icon = this.getIcon();
- if (this.icon) {
- if (!this.icon.visible())
- new Effect.Appear(this.icon);
+ if (icon && !icon.visible()) {
+ new Effect.Appear(this.icon);
}
if (this.errorPopup == undefined)