pari: trunk r817 - /trunk/config/scripts/astman.js

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Fri Apr 27 16:05:55 MST 2007


Author: pari
Date: Fri Apr 27 18:05:54 2007
New Revision: 817

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=817
Log:
Fix: IE getting confused about 'this' in events 

Modified:
    trunk/config/scripts/astman.js

Modified: trunk/config/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/scripts/astman.js?view=diff&rev=817&r1=816&r2=817
==============================================================================
--- trunk/config/scripts/astman.js (original)
+++ trunk/config/scripts/astman.js Fri Apr 27 18:05:54 2007
@@ -1402,14 +1402,16 @@
 
 				if (savewidget) {
 					widgets[x].savewidget = savewidget;
-					add_event( widgets[x] , 'click', function() { this.oldvalue = this.value; return true; });
-					add_event( widgets[x] , 'change', function() { 
-						this.savewidget.activateSave(); 
-						if (this.altonchange){ this.altonchange();} 
+					add_event( widgets[x] , 'click', function(event) { 
+						var t = (event.srcElement)?event.srcElement:this;
+						t.oldvalue = t.value;
+						return true; 
 					});
-				}
-				if (widgets[x].altonchange)
-					widgets[x].altonchange();
+					add_event( widgets[x] , 'change', function(event) {
+						var t = (event.srcElement)?event.srcElement:this;
+						t.savewidget.activateSave();
+					});
+				}
 
 			} else if (widgets[x].type) {
 				if (!cat) {
@@ -1452,22 +1454,27 @@
 				if (savewidget) {
 					widgets[x].savewidget = savewidget;
 					if ((widgets[x].type == 'checkbox') || (widgets[x].type == 'radio')) {
-						add_event( widgets[x] , 'click', function() { this.savewidget.activateSave(); if (this.altonclick){this.altonclick();} });
-						if (widgets[x].altonclick)
-							widgets[x].altonclick();
+						add_event( widgets[x] , 'click', function(event) {
+							var t = (event.srcElement)?event.srcElement:this;
+							t.savewidget.activateSave();
+						});
 					} else {
 
-						add_event( widgets[x] , 'keydown', function() { this.oldvalue = this.value; return true; });
-
-						add_event( widgets[x] , 'keyup', function() { 
-							if (this.oldvalue == this.value){return true;}
-							pattern = this.getAttribute('pattern');
-							if (pattern && check_pattern(pattern, this.oldvalue) && !check_pattern(pattern, this.value)) {
-								this.value = this.oldvalue;
+						add_event( widgets[x] , 'keydown', function(event) {
+							var t = (event.srcElement)?event.srcElement:this;
+							t.oldvalue = t.value; return true; 
+						});
+
+						add_event( widgets[x] , 'keyup', function(event) {
+							var t = (event.srcElement)?event.srcElement:this; 
+							if (t.oldvalue == t.value){return true;}
+							pattern = t.getAttribute('pattern');
+							if (pattern && check_pattern(pattern, t.oldvalue) && !check_pattern(pattern, t.value)) {
+								t.value = t.oldvalue;
 								gui_feedback('Invalid Character !','red');
 							} else{
 								gui_feedback('','default',10);
-								this.savewidget.activateSave();
+								t.savewidget.activateSave();
 							}
 							return true;
 						});
@@ -1655,30 +1662,30 @@
 		if (widgets['save']) {
 			widgets['save'].hostselectbox = box;
 
-			add_event( widgets['save'] , 'click', function() { save_item(this.hostselectbox); });
+			add_event( widgets['save'] , 'click', function(event) { var t = (event.srcElement)?event.srcElement:this; save_item(t.hostselectbox); });
 
 		}
 		if (widgets['cancel']) {
 			widgets['cancel'].hostselectbox = box;
-			add_event( widgets['cancel'] , 'click', function() { cancel_item(this.hostselectbox); });
+			add_event( widgets['cancel'] , 'click', function(event) { var t = (event.srcElement)?event.srcElement:this; cancel_item(t.hostselectbox); });
 		}
 
 		if (widgets['new']) {
 			widgets['new'].hostselectbox = box;
 			widgets['new'].disabled = false;
-			add_event( widgets['new'] , 'click', function() { new_item(this.hostselectbox); });
+			add_event( widgets['new'] , 'click', function(event) { var t = (event.srcElement)?event.srcElement:this; new_item(t.hostselectbox); });
 
 		}
 		if (widgets['newitem']) {
 			widgets['newitem'].hostselectbox = box;
 			widgets['newitem'].disabled = false;
-			add_event( widgets['newitem'] , 'click', function() { new_subitem(this.hostselectbox); });
+			add_event( widgets['newitem'] , 'click', function(event) {var t = (event.srcElement)?event.srcElement:this; new_subitem(t.hostselectbox); });
 
 		}
 		if (widgets['delete']) {
 			widgets['delete'].hostselectbox = box;
 			widgets['delete'].disabled = true;
-			add_event( widgets['delete'] , 'click', function() { delete_item(this.hostselectbox); });
+			add_event( widgets['delete'] , 'click', function(event) {var t = (event.srcElement)?event.srcElement:this; delete_item(t.hostselectbox); });
 		}
 		tmp = new Ajax.Request(this.url, opt);
 	};



More information about the asterisk-gui-commits mailing list