summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorgodzilla80@gmx.net <>2010-02-20 15:46:42 +0000
committergodzilla80@gmx.net <>2010-02-20 15:46:42 +0000
commit63e85cd71abec981fde911c7f8a09daa43306ced (patch)
tree62a04607764c492ac2cba89250f7d2f4184ff539 /framework
parenta1d65f3737980658e9a5dd12165860e35e435941 (diff)
EHN: Clientside performance (micro)optimization: Declare local javascript variables explicit as local to avoid scope chain lookups
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/Javascripts/source/prado/activecontrols/ajax3.js6
-rw-r--r--framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js14
-rwxr-xr-xframework/Web/Javascripts/source/prado/activefileupload/activefileupload.js2
-rw-r--r--framework/Web/Javascripts/source/prado/colorpicker/colorpicker.js2
-rw-r--r--framework/Web/Javascripts/source/prado/controls/controls.js16
-rw-r--r--framework/Web/Javascripts/source/prado/datepicker/datepicker.js6
-rw-r--r--framework/Web/Javascripts/source/prado/prado.js1
-rw-r--r--framework/Web/Javascripts/source/prado/scriptaculous-adapter.js22
-rw-r--r--framework/Web/Javascripts/source/prado/validator/validation3.js19
9 files changed, 46 insertions, 42 deletions
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js
index 331a1f79..d2c6f5fd 100644
--- a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js
+++ b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js
@@ -269,7 +269,7 @@ Object.extend(Prado.CallbackRequest,
*/
onException : function(request,e)
{
- msg = "";
+ var msg = "";
$H(e).each(function(item)
{
msg += item.key+": "+item.value+"\n";
@@ -662,7 +662,7 @@ Prado.CallbackRequest.prototype = Object.extend(Prado.AjaxRequest.prototype,
//IE will try to get elements with ID == name as well.
if(element.type && element.name == name)
{
- value = $F(element);
+ var value = $F(element);
if(typeof(value) != "undefined" && value != null)
data[name] = value;
}
@@ -701,7 +701,7 @@ Prado.Callback = function(UniqueID, parameter, onSuccess, options)
Object.extend(callback, options || {});
- request = new Prado.CallbackRequest(UniqueID, callback);
+ var request = new Prado.CallbackRequest(UniqueID, callback);
request.dispatch();
return false;
};
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js
index 4d0facc2..547f09dc 100644
--- a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js
+++ b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js
@@ -89,8 +89,8 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
{
this.editField.disabled = true;
this.onLoadingText();
- options = new Array('__InlineEditor_loadExternalText__', this.getText());
- request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
+ var options = new Array('__InlineEditor_loadExternalText__', this.getText());
+ var request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
request.setCausesValidation(false);
request.setCallbackParameter(options);
request.ActiveControl.onSuccess = this.onloadExternalTextSuccess.bind(this);
@@ -103,9 +103,9 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
*/
createTextBox : function()
{
- cssClass= this.element.className || '';
- inputName = this.options.EventTarget;
- options = {'className' : cssClass, name : inputName, id : this.options.TextBoxID};
+ var cssClass= this.element.className || '';
+ var inputName = this.options.EventTarget;
+ var options = {'className' : cssClass, name : inputName, id : this.options.TextBoxID};
if(this.options.TextMode == 'SingleLine')
{
if(this.options.MaxLength > 0)
@@ -168,7 +168,7 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
onTextBoxBlur : function(e)
{
- text = this.element.innerHTML;
+ var text = this.element.innerHTML;
if(this.options.AutoPostBack && text != this.editField.value)
{
if(this.isEditing)
@@ -202,7 +202,7 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
*/
onTextChanged : function(text)
{
- request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
+ var request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
request.setCallbackParameter(text);
request.ActiveControl.onSuccess = this.onTextChangedSuccess.bind(this);
request.ActiveControl.onFailure = this.onTextChangedFailure.bind(this);
diff --git a/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js b/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js
index 222b9fe3..ab0996e4 100755
--- a/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js
+++ b/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js
@@ -50,7 +50,7 @@ Prado.WebUI.TActiveFileUpload = Base.extend(
Object.extend(callback, this.options);
- request = new Prado.CallbackRequest(this.options.EventTarget, callback);
+ var request = new Prado.CallbackRequest(this.options.EventTarget, callback);
request.dispatch();
}
else
diff --git a/framework/Web/Javascripts/source/prado/colorpicker/colorpicker.js b/framework/Web/Javascripts/source/prado/colorpicker/colorpicker.js
index fd361469..164295cd 100644
--- a/framework/Web/Javascripts/source/prado/colorpicker/colorpicker.js
+++ b/framework/Web/Javascripts/source/prado/colorpicker/colorpicker.js
@@ -202,7 +202,7 @@ Rico.Color.HSBtoRGB = function(hue, saturation, brightness) {
Rico.Color.RGBtoHSB = function(r, g, b) {
var hue;
- var saturaton;
+ var saturation;
var brightness;
var cmax = (r > g) ? r : g;
diff --git a/framework/Web/Javascripts/source/prado/controls/controls.js b/framework/Web/Javascripts/source/prado/controls/controls.js
index 463b95a7..14853dca 100644
--- a/framework/Web/Javascripts/source/prado/controls/controls.js
+++ b/framework/Web/Javascripts/source/prado/controls/controls.js
@@ -82,15 +82,15 @@ Object.extend(Prado.WebUI.TImageButton.prototype,
*/
addXYInput : function(event,options)
{
- imagePos = this.element.cumulativeOffset();
- clickedPos = [event.clientX, event.clientY];
- x = clickedPos[0]-imagePos[0]+1;
- y = clickedPos[1]-imagePos[1]+1;
+ var imagePos = this.element.cumulativeOffset();
+ var clickedPos = [event.clientX, event.clientY];
+ var x = clickedPos[0]-imagePos[0]+1;
+ var y = clickedPos[1]-imagePos[1]+1;
x = x < 0 ? 0 : x;
y = y < 0 ? 0 : y;
- id = options['EventTarget'];
- x_input = $(id+"_x");
- y_input = $(id+"_y");
+ var id = options['EventTarget'];
+ var x_input = $(id+"_x");
+ var y_input = $(id+"_y");
if(x_input)
{
x_input.value = x;
@@ -118,7 +118,7 @@ Object.extend(Prado.WebUI.TImageButton.prototype,
*/
removeXYInput : function(event,options)
{
- id = options['EventTarget'];
+ var id = options['EventTarget'];
this.element.parentNode.removeChild($(id+"_x"));
this.element.parentNode.removeChild($(id+"_y"));
}
diff --git a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js
index 9236c32e..8105823a 100644
--- a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js
+++ b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js
@@ -236,11 +236,11 @@ Prado.WebUI.TDatePicker.prototype =
tbody = document.createElement("tbody");
table.appendChild(tbody);
- for(week=0; week<6; ++week) {
+ for(var week=0; week<6; ++week) {
tr = document.createElement("tr");
tbody.appendChild(tr);
- for(day=0; day<7; ++day) {
+ for(var day=0; day<7; ++day) {
td = document.createElement("td");
td.className = "calendarDate";
text = document.createTextNode(String.fromCharCode(160));
@@ -702,7 +702,7 @@ Prado.WebUI.TDatePicker.prototype =
index++;
}
- for (i = 1; i <= monthLength; i++, index++) {
+ for (var i = 1; i <= monthLength; i++, index++) {
var slot = this.dateSlot[index];
var slotNode = slot.data.parentNode;
slot.value = i;
diff --git a/framework/Web/Javascripts/source/prado/prado.js b/framework/Web/Javascripts/source/prado/prado.js
index 9db01b42..d2fc8bdf 100644
--- a/framework/Web/Javascripts/source/prado/prado.js
+++ b/framework/Web/Javascripts/source/prado/prado.js
@@ -85,6 +85,7 @@ var Prado =
elm.rel = "stylesheet";
elm.href = css_file;
+ var headArr;
if (headArr = doc.getElementsByTagName("head"))
headArr[0].appendChild(elm);
diff --git a/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js b/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js
index 5ea71364..626f8b5a 100644
--- a/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js
+++ b/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js
@@ -96,6 +96,7 @@ Base.prototype = {
var _protected = ["toString", "valueOf"];
// if we are prototyping then include the constructor
if (Base._prototyping) _protected[2] = "constructor";
+ var name;
for (var i = 0; (name = _protected[i]); i++) {
if (source[name] != _prototype[name]) {
extend.call(this, name, source[name]);
@@ -237,7 +238,7 @@ Prado.Element =
var selection = Prado.Element.Selection;
if(typeof(selection[method]) == "function")
{
- control = selection.isSelectable(el) ? [el] : selection.getListElements(element,total);
+ var control = selection.isSelectable(el) ? [el] : selection.getListElements(element,total);
selection[method](control, value);
}
},
@@ -396,7 +397,7 @@ Prado.Element =
{
if(boundary)
{
- result = Prado.Element.extractContent(this.transport.responseText, boundary);
+ var result = Prado.Element.extractContent(this.transport.responseText, boundary);
if(result != null)
content = result;
}
@@ -534,7 +535,7 @@ Prado.Element.Selection =
$A(el.options).each(function(option)
{
if(typeof(value) == "boolean")
- options.selected = value;
+ option.selected = value;
else if(option.value == value)
option.selected = true;
});
@@ -549,7 +550,7 @@ Prado.Element.Selection =
*/
selectValues : function(elements, values)
{
- selection = this;
+ var selection = this;
values.each(function(value)
{
selection.selectValue(elements,value);
@@ -625,7 +626,7 @@ Prado.Element.Selection =
*/
selectIndices : function(elements, indices)
{
- selection = this;
+ var selection = this;
indices.each(function(index)
{
selection.selectIndex(elements,index);
@@ -654,8 +655,9 @@ Prado.Element.Selection =
*/
getListElements : function(element, total)
{
- elements = new Array();
- for(i = 0; i < total; i++)
+ var elements = new Array();
+ var el;
+ for(var i = 0; i < total; i++)
{
el = $(element+"_c"+i);
if(el)
@@ -693,7 +695,7 @@ Prado.Element.Selection =
*/
checkValues : function(elements, values)
{
- selection = this;
+ var selection = this;
values.each(function(value)
{
selection.checkValue(elements, value);
@@ -723,7 +725,7 @@ Prado.Element.Selection =
*/
checkIndices : function(elements, indices)
{
- selection = this;
+ var selection = this;
indices.each(function(index)
{
selection.checkIndex(elements, index);
@@ -1236,7 +1238,7 @@ Object.extend(Date,
*/
SimpleParse: function(value, format)
{
- val=String(value);
+ var val=String(value);
format=String(format);
if(val.length <= 0) return null;
diff --git a/framework/Web/Javascripts/source/prado/validator/validation3.js b/framework/Web/Javascripts/source/prado/validator/validation3.js
index b1bf1a03..e24e8ffd 100644
--- a/framework/Web/Javascripts/source/prado/validator/validation3.js
+++ b/framework/Web/Javascripts/source/prado/validator/validation3.js
@@ -1113,11 +1113,11 @@ Prado.WebUI.TBaseValidator.prototype =
case 'TDatePicker':
if(control.type == "text")
{
- value = this.trim($F(control));
+ var value = this.trim($F(control));
if(this.options.DateFormat)
{
- date = value.toDate(this.options.DateFormat);
+ var date = value.toDate(this.options.DateFormat);
return date == null ? value : date;
}
else
@@ -1154,7 +1154,7 @@ Prado.WebUI.TBaseValidator.prototype =
*/
getValidationValue : function(control)
{
- value = this.getRawValidationValue(control);
+ var value = this.getRawValidationValue(control);
if(Object.isString(value))
return this.trim(value);
else
@@ -1168,8 +1168,8 @@ Prado.WebUI.TBaseValidator.prototype =
*/
getRadioButtonGroupValue : function()
{
- name = this.control.name;
- value = "";
+ var name = this.control.name;
+ var value = "";
$A(document.getElementsByName(name)).each(function(el)
{
if(el.checked)
@@ -1242,6 +1242,7 @@ Prado.WebUI.TBaseValidator.prototype =
case 'TListBox':
var elements = [];
var element = $(this.options.ControlToValidate);
+ var type;
if(element && (type = element.type.toLowerCase()))
{
if(type == "select-one" || type == "select-multiple")
@@ -1475,7 +1476,7 @@ Prado.WebUI.TCustomValidator = Class.extend(Prado.WebUI.TBaseValidator,
var clientFunction = this.options.ClientValidationFunction;
if(typeof(clientFunction) == "string" && clientFunction.length > 0)
{
- validate = clientFunction.toFunction();
+ var validate = clientFunction.toFunction();
return validate(this, value);
}
return true;
@@ -1551,11 +1552,11 @@ Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator,
*/
evaluateIsValid : function()
{
- value = this.getValidationValue();
+ var value = this.getValidationValue();
if(!this.requestDispatched && (""+value) != (""+this.validatingValue))
{
this.validatingValue = value;
- request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
+ var request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
if(this.options.DateFormat && value instanceof Date) //change date to string with formatting.
value = value.SimpleFormat(this.options.DateFormat);
request.setCallbackParameter(value);
@@ -1848,7 +1849,7 @@ Prado.WebUI.TDataTypeValidator = Class.extend(Prado.WebUI.TBaseValidator,
*/
evaluateIsValid : function()
{
- value = this.getValidationValue();
+ var value = this.getValidationValue();
if(value.length <= 0)
return true;
return this.convert(this.options.DataType, value) != null;