From: Argiris K. <be...@us...> - 2006-02-08 16:20:54
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11668/Core/script Modified Files: AjaxCallObject.js Log Message: Fixed client validation for doPostBack (LinkButton etc.) and various other fixes. Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** AjaxCallObject.js 6 Feb 2006 01:39:35 -0000 1.53 --- AjaxCallObject.js 8 Feb 2006 16:19:55 -0000 1.54 *************** *** 8,13 **** __ClockID = 0; __IsOpera = false; ! __Netscape8AndUp = false; ! __ClickX = __ClickY = 0; // Excluding from post flags --- 8,13 ---- __ClockID = 0; __IsOpera = false; ! __IsIE = false; ! __ClkEvent = null; // Excluding from post flags *************** *** 196,203 **** } ! AjaxCallObject.prototype.AddEventListener = function(obj, eventName, fn) { if (obj.addEventListener) ! obj.addEventListener(eventName, fn, false); else obj.attachEvent("on"+eventName, fn); --- 196,204 ---- } ! AjaxCallObject.prototype.AddEventListener = function(obj, eventName, fn, capture) { + if (typeof(capture)=="undefined") capture=false; if (obj.addEventListener) ! obj.addEventListener(eventName, fn, capture); else obj.attachEvent("on"+eventName, fn); *************** *** 218,226 **** AjaxCallObject.prototype.HookAjaxCall = function(bPageIsStored, bUnloadStoredPage, bTracing) { ! __Netscape8AndUp = navigator.appName == "Netscape" && navigator.vendor == "Netscape" && parseInt(navigator.appVersion) >= 5; __IsOpera = window.opera ? true : false; this.AddEventListener(document.forms[0], "submit", this.OnFormSubmit); ! this.AddEventListener(document.forms[0], "click", this.OnFormClick); if (typeof __doPostBack != 'undefined') --- 219,227 ---- AjaxCallObject.prototype.HookAjaxCall = function(bPageIsStored, bUnloadStoredPage, bTracing) { ! __IsIE = navigator.appName.indexOf("Internet Explorer") != -1; __IsOpera = window.opera ? true : false; this.AddEventListener(document.forms[0], "submit", this.OnFormSubmit); ! this.AddEventListener(document.forms[0], "click", this.OnFormClick, true); if (typeof __doPostBack != 'undefined') *************** *** 251,256 **** AjaxCallObject.prototype.OnFormClick = function(e) { ! __ClickX = e.pageX; ! __ClickY = e.pageY; } --- 252,256 ---- AjaxCallObject.prototype.OnFormClick = function(e) { ! __ClkEvent = e; } *************** *** 259,278 **** if (__doingSubmit) { if (e.preventDefault) e.preventDefault(); return false; } ! if (e.getPreventDefault) ! { ! if (e.getPreventDefault() == true) ! return false; ! } ! else if (!__IsOpera && "returnValue" in e) { ! if (e.returnValue == false) ! return false; } ! // Empty the cached html of RenderedByScript controls if (typeof(RBS_Controls) != "undefined") --- 259,280 ---- if (__doingSubmit) { + __doingSubmit = false; if (e.preventDefault) e.preventDefault(); + e.returnValue=false; return false; } ! if (typeof(WebForm_OnSubmit)=="function") { ! if (window.event && !__IsOpera) ! { ! if (window.event.returnValue == false) ! return; ! } ! else if (e.getPreventDefault && e.getPreventDefault() == true) ! return; } ! // Empty the cached html of RenderedByScript controls if (typeof(RBS_Controls) != "undefined") *************** *** 291,297 **** { // Firefox ! target = arguments[0] ? arguments[0].explicitOriginalTarget : null; } var cbType = AJAXCbo.GetAjaxCallType(target); if (cbType != "none") --- 293,302 ---- { // Firefox ! target = e ? e.explicitOriginalTarget : null; } + if (target == null || target.name == null || target.name == "") + return true; + var cbType = AJAXCbo.GetAjaxCallType(target); if (cbType != "none") *************** *** 303,307 **** var theData = ""; //check if target is an input element of type 'image' ! if (target != null && target.type == "image" && target.name && target.name != '') { if (e.offsetX) --- 308,312 ---- var theData = ""; //check if target is an input element of type 'image' ! if (target != null && target.type == "image") { if (e.offsetX) *************** *** 313,317 **** { // Firefox ! theData = target.name + ".x=" + (__ClickX - target.offsetLeft) + "&" + target.name + ".y=" + (__ClickY - target.offsetTop); } } --- 318,322 ---- { // Firefox ! theData = target.name + ".x=" + (__ClkEvent.pageX - target.offsetLeft) + "&" + target.name + ".y=" + (__ClkEvent.pageY - target.offsetTop); } } *************** *** 321,324 **** --- 326,330 ---- if (e.preventDefault) e.preventDefault(); + e.returnValue = false; return false; } *************** *** 336,339 **** --- 342,352 ---- AjaxCallObject.prototype.DoPostBack = function(eventTarget, eventArgument) { + if (typeof(WebForm_OnSubmit)=="function") + { + var theForm = document.forms[0]; + if (theForm.onsubmit && (theForm.onsubmit() == false)) + return; + } + // Empty the cached html of RenderedByScript controls if (typeof(RBS_Controls) != "undefined") *************** *** 347,355 **** if (cbType != "none") { - __doingSubmit = true; - AJAXCbo.DispatchEvent(document.forms[0], "submit"); - __doingSubmit = false; - AJAXCbo.DoAjaxCall(eventTarget, eventArgument, cbType, AJAXCbo.GetAjaxScopeID(target)); } else --- 360,374 ---- if (cbType != "none") { AJAXCbo.DoAjaxCall(eventTarget, eventArgument, cbType, AJAXCbo.GetAjaxScopeID(target)); + + if (window.event) + { + window.event.returnValue = false; + } + else if (__ClkEvent) + { + if (__ClkEvent.preventDefault) + __ClkEvent.preventDefault(); + } } else *************** *** 570,573 **** --- 589,606 ---- eval(responseText); + + // Remove validators whose controltovalidate have been removed + if (typeof(Page_Validators)!="undefined") + { + for (i=0; i<Page_Validators.length; i++) + { + if (Page_Validators[i] && Page_Validators[i].controltovalidate + && document.getElementById(Page_Validators[i].controltovalidate)==null) + { + Page_Validators.splice(i,1); + i--; + } + } + } return true; *************** *** 935,946 **** } ! if (__Netscape8AndUp) { ! //Netscape 8 has a problem using replaceChild when replaced child contains a table place.parentNode.insertBefore(store, place); place.parentNode.removeChild(place); } - else - place.parentNode.replaceChild(store, place); place = null; //cleanup --- 968,979 ---- } ! if (__IsIE) ! place.parentNode.replaceChild(store, place); ! else { ! //Netscape/Firefox has a problem using replaceChild when replaced child contains a table place.parentNode.insertBefore(store, place); place.parentNode.removeChild(place); } place = null; //cleanup |