From 418baf36d477bcbdd6fb4eaf4037ea6a2d93f21c Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 4 Dec 2005 17:51:05 +0000 Subject: --- .gitattributes | 3 +- framework/Web/Javascripts/WebForms.js | 298 --------- framework/Web/Javascripts/js/base.js | 966 ++++++++++++++++++++++++++++++ framework/Web/UI/TClientScriptManager.php | 19 +- framework/Web/UI/TForm.php | 3 +- framework/Web/UI/TPage.php | 50 +- framework/Web/UI/TPostBackOptions.php | 34 -- 7 files changed, 995 insertions(+), 378 deletions(-) delete mode 100644 framework/Web/Javascripts/WebForms.js create mode 100644 framework/Web/Javascripts/js/base.js delete mode 100644 framework/Web/UI/TPostBackOptions.php diff --git a/.gitattributes b/.gitattributes index 7f95dbe2..225c7db8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -68,7 +68,7 @@ framework/Security/TUserManager.php -text framework/TApplication.php -text framework/TComponent.php -text framework/TODO.txt -text -framework/Web/Javascripts/WebForms.js -text +framework/Web/Javascripts/js/base.js -text framework/Web/Services/TPageService.php -text framework/Web/THttpRequest.php -text framework/Web/THttpResponse.php -text @@ -81,7 +81,6 @@ framework/Web/UI/TForm.php -text framework/Web/UI/THiddenFieldPageStatePersister.php -text framework/Web/UI/THtmlWriter.php -text framework/Web/UI/TPage.php -text -framework/Web/UI/TPostBackOptions.php -text framework/Web/UI/TTemplateControl.php -text framework/Web/UI/TTemplateManager.php -text framework/Web/UI/TThemeManager.php -text diff --git a/framework/Web/Javascripts/WebForms.js b/framework/Web/Javascripts/WebForms.js deleted file mode 100644 index 79e0eeaa..00000000 --- a/framework/Web/Javascripts/WebForms.js +++ /dev/null @@ -1,298 +0,0 @@ -function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit) { - this.eventTarget = eventTarget; - this.eventArgument = eventArgument; - this.validation = validation; - this.validationGroup = validationGroup; - this.actionUrl = actionUrl; - this.trackFocus = trackFocus; - this.clientSubmit = clientSubmit; -} -function WebForm_DoPostBackWithOptions(options) { - var validationResult = true; - if (options.validation) { - if (typeof(Page_ClientValidate) == 'function') { - validationResult = Page_ClientValidate(options.validationGroup); - } - } - if (validationResult) { - if ((typeof(options.actionUrl) != "undefined") && (options.actionUrl != null) && (options.actionUrl.length > 0)) { - theForm.action = options.actionUrl; - } - if (options.trackFocus) { - var lastFocus = theForm.elements["__LASTFOCUS"]; - if ((typeof(lastFocus) != "undefined") && (lastFocus != null)) { - if (typeof(document.activeElement) == "undefined") { - lastFocus.value = options.eventTarget; - } - else { - var active = document.activeElement; - if ((typeof(active.id) != "undefined") && (active != null)) { - if ((typeof(active.id) != "undefined") && (active.id != null) && (active.id.length > 0)) { - lastFocus.value = active.id; - } - else if (typeof(active.name) != "undefined") { - lastFocus.value = active.name; - } - } - } - } - } - } - if (options.clientSubmit) { - __doPostBack(options.eventTarget, options.eventArgument); - } -} -var __callbackObject = new Object(); -function WebForm_DoCallback(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync) { - var postData = __theFormPostData + - "__CALLBACKID=" + WebForm_EncodeCallback(eventTarget) + - "&__CALLBACKPARAM=" + WebForm_EncodeCallback(eventArgument); - var xmlRequest; - var usePost = false; - if (__nonMSDOMBrowser) { - // http: - // And: http: - xmlRequest = new XMLHttpRequest(); - if (pageUrl.length + postData.length + 1 > 10000) { - usePost = true; - } - if (usePost) { - xmlRequest.open("POST", pageUrl, false); - xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - xmlRequest.send(postData); - } - else { - if (pageUrl.indexOf("?") != -1) { - xmlRequest.open("GET", pageUrl + "&" + postData, false); - } - else { - xmlRequest.open("GET", pageUrl + "?" + postData, false); - } - xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - xmlRequest.send(null); - } - var response = xmlRequest.responseText; - if (response.charAt(0) == "s") { - if ((typeof(eventCallback) != "undefined") && (eventCallback != null)) { - eventCallback(response.substring(1), context); - } - } - else { - if ((typeof(errorCallback) != "undefined") && (errorCallback != null)) { - errorCallback(response.substring(1), context); - } - } - } - else { - xmlRequest = new ActiveXObject("Microsoft.XMLHTTP"); - xmlRequest.onreadystatechange = WebForm_CallbackComplete; - __callbackObject.xmlRequest = xmlRequest; - __callbackObject.eventCallback = eventCallback; - __callbackObject.context = context; - __callbackObject.errorCallback = errorCallback; - if (pageUrl.length + postData.length + 1 > 2067) { - usePost = true; - } - if (usePost) { - xmlRequest.open("POST", pageUrl, useAsync); - xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - xmlRequest.send(postData); - } - else { - if (pageUrl.indexOf("?") != -1) { - xmlRequest.open("GET", pageUrl + "&" + postData, useAsync); - } - else { - xmlRequest.open("GET", pageUrl + "?" + postData, useAsync); - } - xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - xmlRequest.send(); - } - } -} -function WebForm_CallbackComplete() { - if (__callbackObject.xmlRequest.readyState == 4) { - var response = __callbackObject.xmlRequest.responseText; - if (response.charAt(0) == "s") { - if ((typeof(__callbackObject.eventCallback) != "undefined") && (__callbackObject.eventCallback != null)) { - __callbackObject.eventCallback(response.substring(1), __callbackObject.context); - } - } - else { - if ((typeof(__callbackObject.errorCallback) != "undefined") && (__callbackObject.errorCallback != null)) { - __callbackObject.errorCallback(response.substring(1), __callbackObject.context); - } - } - } -} -var __nonMSDOMBrowser = (window.navigator.appName.toLowerCase().indexOf('explorer') == -1); -var __theFormPostData = ""; -function WebForm_InitCallback() { - var count = theForm.elements.length; - var element; - for (var i = 0; i < count; i++) { - element = theForm.elements[i]; - var tagName = element.tagName.toLowerCase(); - if (tagName == "input") { - var type = element.type; - if (type == "text" || type == "hidden" || type == "password" || - ((type == "checkbox" || type == "radio") && element.checked)) { - __theFormPostData += element.name + "=" + WebForm_EncodeCallback(element.value) + "&"; - } - } - else if (tagName == "select") { - var selectCount = element.children.length; - for (var j = 0; j < selectCount; j++) { - var selectChild = element.children[j]; - if ((selectChild.tagName.toLowerCase() == "option") && (selectChild.selected == true)) { - __theFormPostData += element.name + "=" + WebForm_EncodeCallback(selectChild.value) + "&"; - } - } - } - else if (tagName == "textarea") { - __theFormPostData += element.name + "=" + WebForm_EncodeCallback(element.value) + "&"; - } - } -} -function WebForm_EncodeCallback(parameter) { - if (encodeURIComponent) { - return encodeURIComponent(parameter); - } - else { - return escape(parameter); - } -} -var __disabledControlArray = new Array(); -function WebForm_ReEnableControls() { - if (typeof(__enabledControlArray) == 'undefined') { - return false; - } - var disabledIndex = 0; - for (var i = 0; i < __enabledControlArray.length; i++) { - var c; - if (__nonMSDOMBrowser) { - c = document.getElementById(__enabledControlArray[i]); - } - else { - c = document.all[__enabledControlArray[i]]; - } - if ((typeof(c) != "undefined") && (c != null) && (c.disabled == true)) { - c.disabled = false; - __disabledControlArray[disabledIndex++] = c; - } - } - setTimeout("WebForm_ReDisableControls()", 0); - return true; -} -function WebForm_ReDisableControls() { - for (var i = 0; i < __disabledControlArray.length; i++) { - __disabledControlArray[i].disabled = true; - } -} -var __defaultFired = false; -function WebForm_FireDefaultButton(event, target) { - if (!__defaultFired && event.keyCode == 13) { - var defaultButton; - if (__nonMSDOMBrowser) { - defaultButton = document.getElementById(target); - } - else { - defaultButton = document.all[target]; - } - if (defaultButton.click != "undefined") { - __defaultFired = true; - defaultButton.click(); - event.cancelBubble = true; - return false; - } - } - return true; -} -function WebForm_GetScrollX() { - if (__nonMSDOMBrowser) { - return window.pageXOffset; - } - else { - if (document.documentElement && document.documentElement.scrollLeft) { - return document.documentElement.scrollLeft; - } - else if (document.body) { - return document.body.scrollLeft; - } - } - return 0; -} -function WebForm_GetScrollY() { - if (__nonMSDOMBrowser) { - return window.pageYOffset; - } - else { - if (document.documentElement && document.documentElement.scrollTop) { - return document.documentElement.scrollTop; - } - else if (document.body) { - return document.body.scrollTop; - } - } - return 0; -} -function WebForm_SaveScrollPositionSubmit() { - if (__nonMSDOMBrowser) { - theForm.elements['__SCROLLPOSITIONY'].value = window.pageYOffset; - theForm.elements['__SCROLLPOSITIONX'].value = window.pageXOffset; - } - else { - theForm.__SCROLLPOSITIONX.value = WebForm_GetScrollX(); - theForm.__SCROLLPOSITIONY.value = WebForm_GetScrollY(); - } - if ((typeof(WebForm_ScrollPositionSubmit) != "undefined") && (WebForm_ScrollPositionSubmit != null)) { - if (WebForm_ScrollPositionSubmit.apply) { - return WebForm_ScrollPositionSubmit.apply(this); - } - else { - return WebForm_ScrollPositionSubmit(); - } - } - return true; -} -function WebForm_SaveScrollPositionOnSubmit() { - theForm.__SCROLLPOSITIONX.value = WebForm_GetScrollX(); - theForm.__SCROLLPOSITIONY.value = WebForm_GetScrollY(); - if ((typeof(WebForm_ScrollPositionOnSubmit) != "undefined") && (WebForm_ScrollPositionOnSubmit != null)) { - if (WebForm_ScrollPositionOnSubmit.apply) { - return WebForm_ScrollPositionOnSubmit.apply(this); - } - else { - return WebForm_ScrollPositionOnSubmit(); - } - } - return true; -} -function WebForm_RestoreScrollPosition() { - if (__nonMSDOMBrowser) { - window.scrollTo(theForm.elements['__SCROLLPOSITIONX'].value, theForm.elements['__SCROLLPOSITIONY'].value); - } - else { - window.scrollTo(theForm.__SCROLLPOSITIONX.value, theForm.__SCROLLPOSITIONY.value); - } - if ((typeof(WebForm_ScrollPositionLoad) != "undefined") && (WebForm_ScrollPositionLoad != null)) { - if (WebForm_ScrollPositionLoad.apply) { - return WebForm_ScrollPositionLoad.apply(this); - } - else { - return WebForm_ScrollPositionLoad(); - } - } - return true; -} -function WebForm_TextBoxKeyHandler() { - if (event.keyCode == 13) { - if ((typeof(event.srcElement) != "undefined") && (event.srcElement != null)) { - if (typeof(event.srcElement.onchange) != "undefined") { - event.srcElement.onchange(); - return false; - } - } - } - return true; -} diff --git a/framework/Web/Javascripts/js/base.js b/framework/Web/Javascripts/js/base.js new file mode 100644 index 00000000..fdd4ee8f --- /dev/null +++ b/framework/Web/Javascripts/js/base.js @@ -0,0 +1,966 @@ +var Prototype={Version:"1.4.0_rc1",emptyFunction:function(){ +},K:function(x){ +return x; +}}; + +if(!Array.prototype.push){ +Array.prototype.push=function(){ +var _1=this.length; +for(var i=0;i0&&parent.frames.length){ +d=parent.frames[n.substring(p+1)].document; +n=n.substring(0,p); +} +if(!(x=d[n])&&d.all){ +x=d.all[n]; +} +for(i=0;!x&&i]+>/gi,""); +},escapeHTML:function(){ +var _1=document.createElement("div"); +var _2=document.createTextNode(this); +_1.appendChild(_2); +return _1.innerHTML; +},unescapeHTML:function(){ +var _3=document.createElement("div"); +_3.innerHTML=this.stripTags(); +return _3.childNodes[0]?_3.childNodes[0].nodeValue:""; +},toQueryParams:function(){ +var _4=this.match(/^\??(.*)$/)[1].split("&"); +return _4.inject({},function(_5,_6){ +var _7=_6.split("="); +_5[_7[0]]=_7[1]; +return _5; +}); +},toArray:function(){ +return this.split(""); +},camelize:function(){ +var _8=this.split("-"); +if(_8.length==1){ +return _8[0]; +} +var _9=this.indexOf("-")==0?_8[0].charAt(0).toUpperCase()+_8[0].substring(1):_8[0]; +for(var i=1,len=_8.length;i=(_41||_42)){ +_41=_42; +} +}); +return _41; +},min:function(_44){ +var _45; +this.each(function(_46,_47){ +_46=(_44||Prototype.K)(_46,_47); +if(_46<=(_45||_46)){ +_45=_46; +} +}); +return _45; +},partition:function(_48){ +var _49=[],falses=[]; +this.each(function(_50,_51){ +((_48||Prototype.K)(_50,_51)?_49:falses).push(_50); +}); +return [_49,falses]; +},pluck:function(_52){ +var _53=[]; +this.each(function(_54,_55){ +_53.push(_54[_52]); +}); +return _53; +},reject:function(_56){ +var _57=[]; +this.each(function(_58,_59){ +if(!_56(_58,_59)){ +_57.push(_58); +} +}); +return _57; +},sortBy:function(_60){ +return this.collect(function(_61,_62){ +return {value:_61,criteria:_60(_61,_62)}; +}).sort(function(_63,_64){ +var a=_63.criteria,b=_64.criteria; +return ab?1:0; +}).pluck("value"); +},toArray:function(){ +return this.collect(Prototype.K); +},zip:function(){ +var _66=Prototype.K,args=$A(arguments); +if(typeof args.last()=="function"){ +_66=args.pop(); +} +var _67=[this].concat(args).map($A); +return this.map(function(_68,_69){ +_66(_68=_67.pluck(_69)); +return _68; +}); +},inspect:function(){ +return "#"; +}}; +Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray}); + +var $A=Array.from=function(_1){ +if(_1.toArray){ +return _1.toArray(); +}else{ +var _2=[]; +for(var i=0;i<_1.length;i++){ +_2.push(_1[i]); +} +return _2; +} +}; +Object.extend(Array.prototype,Enumerable); +Object.extend(Array.prototype,{_each:function(_4){ +for(var i=0;i0;i--){ +_11.push(this[i-1]); +} +return _11; +},inspect:function(){ +return "["+this.map(Object.inspect).join(", ")+"]"; +}}); + +Array.prototype.indexOf=function(_1,_2,_3){ +_2=_2||0; +for(var i=_2;ithis[i]){ +n=this[i]; +} +} +return n; +}; +Array.prototype.max=function(){ +if(!this.length){ +return; +} +var n=this[0]; +for(var i=1;i0; +}; +Array.prototype.each=function(fn){ +return each(this,fn); +}; +Array.prototype.map=function(fn){ +return map(this,fn); +}; +Array.prototype.filter=function(fn){ +return filter(this,fn); +}; +Array.prototype.select=Array.prototype.filter; +Array.prototype.reduce=function(){ +var _24=map(arguments); +fn=_24.pop(); +d=_24.pop(); +return reduce(this,d,fn); +}; +Array.prototype.inject=Array.prototype.reduce; +Array.prototype.reject=function(fn){ +if(typeof (fn)=="string"){ +fn=__strfn("item,idx,list",fn); +} +var _25=this; +var _26=[]; +fn=fn||function(v){ +return v; +}; +map(_25,function(_28,idx,_29){ +if(fn(_28,idx,_29)){ +_26.push(idx); +} +}); +_26.reverse().each(function(idx){ +_25.splice(idx,1); +}); +return _25; +}; +function __strfn(_30,fn){ +function quote(s){ +return "\""+s.replace(/"/g,"\\\"")+"\""; +} +if(!/\breturn\b/.test(fn)){ +fn=fn.replace(/;\s*$/,""); +fn=fn.insert(fn.lastIndexOf(";")+1," return "); +} +return eval("new Function("+map(_30.split(/\s*,\s*/),quote).join()+","+quote(fn)+")"); +} +function each(_32,fn){ +if(typeof (fn)=="string"){ +return each(_32,__strfn("item,idx,list",fn)); +} +for(var i=0;i<_32.length;i++){ +fn(_32[i],i,_32); +} +} +function map(_33,fn){ +if(typeof (fn)=="string"){ +return map(_33,__strfn("item,idx,list",fn)); +} +var _34=[]; +fn=fn||function(v){ +return v; +}; +for(var i=0;i<_33.length;i++){ +_34.push(fn(_33[i],i,_33)); +} +return _34; +} +function combine(){ +var _35=map(arguments); +var _36=map(_35.slice(0,-1),"map(item)"); +var fn=_35.last(); +var _37=map(_36,"item.length").max(); +var _38=[]; +if(!fn){ +fn=function(){ +return map(arguments); +}; +} +if(typeof fn=="string"){ +if(_36.length>26){ +throw "string functions can take at most 26 lists"; +} +var a="a".charCodeAt(0); +fn=__strfn(map(range(a,a+_36.length),"String.fromCharCode(item)").join(","),fn); +} +map(_36,function(li){ +while(li.length<_37){ +li.push(null); +} +map(li,function(_40,ix){ +if(ix<_38.length){ +_38[ix].push(_40); +}else{ +_38.push([_40]); +} +}); +}); +return map(_38,function(val){ +return fn.apply(fn,val); +}); +} +function filter(_43,fn){ +if(typeof (fn)=="string"){ +return filter(_43,__strfn("item,idx,list",fn)); +} +var _44=[]; +fn=fn||function(v){ +return v; +}; +map(_43,function(_45,idx,_43){ +if(fn(_45,idx,_43)){ +_44.push(_45); +} +}); +return _44; +} +function reduce(_46,_47,fn){ +if(undef(fn)){ +fn=_47; +_47=window.undefined; +} +if(typeof (fn)=="string"){ +return reduce(_46,_47,__strfn("a,b",fn)); +} +if(isdef(_47)){ +_46.splice(0,0,_47); +} +if(_46.length===0){ +return false; +} +if(_46.length===1){ +return _46[0]; +} +var _48=_46[0]; +var i=1; +while(i<_46.length){ +_48=fn(_48,_46[i++]); +} +return _48; +} +function range(_49,_50,_51){ +if(isUndefined(_50)){ +return range(0,_49,_51); +} +if(isUndefined(_51)){ +_51=1; +} +var ss=(_51/Math.abs(_51)); +var r=[]; +for(i=_49;i*ss<_50*ss;i=i+_51){ +r.push(i); +} +return r; +} + +var Hash={_each:function(_1){ +for(key in this){ +var _2=this[key]; +if(typeof _2=="function"){ +continue; +} +var _3=[key,_2]; +_3.key=key; +_3.value=_2; +_1(_3); +} +},keys:function(){ +return this.pluck("key"); +},values:function(){ +return this.pluck("value"); +},merge:function(_4){ +return $H(_4).inject($H(this),function(_5,_6){ +_5[_6.key]=_6.value; +return _5; +}); +},toQueryString:function(){ +return this.map(function(_7){ +return _7.map(encodeURIComponent).join("="); +}).join("&"); +},inspect:function(){ +return "#"; +}}; +function $H(_9){ +var _10=Object.extend({},_9||{}); +Object.extend(_10,Enumerable); +Object.extend(_10,Hash); +return _10; +} + +var Range=Class.create(); +Object.extend(Range.prototype,Enumerable); +Object.extend(Range.prototype,{initialize:function(_1,_2,_3){ +this.start=_1; +this.end=_2; +this.exclusive=_3; +},_each:function(_4){ +var _5=this.start; +do{ +_4(_5); +_5=_5.succ(); +}while(this.include(_5)); +},include:function(_6){ +if(_60)){ +_10.action=_9.actionUrl; +} +if(_9.trackFocus){ +var _12=_10.elements["PRADO_LASTFOCUS"]; +if((typeof (_12)!="undefined")&&(_12!=null)){ +var _13=document.activeElement; +if(typeof (_13)=="undefined"){ +_12.value=_7; +}else{ +if((_13!=null)&&(typeof (_13.id)!="undefined")){ +if(_13.id.length>0){ +_12.value=_13.id; +}else{ +if(typeof (_13.name)!="undefined"){ +_12.value=_13.name; +} +} +} +} +} +} +if(!_9.clientSubmit){ +_11=false; +} +} +} +if(_11&&(!_10.onsubmit||_10.onsubmit())){ +_10.PRADO_POSTBACK_TARGET.value=_7; +_10.PRADO_POSTBACK_PARAMETER.value=_8; +_10.submit(); +} +}; + +Prado.Focus=Class.create(); +Prado.Focus.setFocus=function(id){ +var _2=document.getElementById?document.getElementById(id):document.all[id]; +if(_2&&!Prado.Focus.canFocusOn(_2)){ +_2=Prado.Focus.findTarget(_2); +} +if(_2){ +try{ +_2.focus(); +_2.scrollIntoView(false); +if(window.__smartNav){ +window.__smartNav.ae=_2.id; +} +} +catch(e){ +} +} +}; +Prado.Focus.canFocusOn=function(_3){ +if(!_3||!(_3.tagName)){ +return false; +} +var _4=_3.tagName.toLowerCase(); +return !_3.disabled&&(!_3.type||_3.type.toLowerCase()!="hidden")&&Prado.Focus.isFocusableTag(_4)&&Prado.Focus.isVisible(_3); +}; +Prado.Focus.isFocusableTag=function(_5){ +return (_5=="input"||_5=="textarea"||_5=="select"||_5=="button"||_5=="a"); +}; +Prado.Focus.findTarget=function(_6){ +if(!_6||!(_6.tagName)){ +return null; +} +var _7=_6.tagName.toLowerCase(); +if(_7=="undefined"){ +return null; +} +var _8=_6.childNodes; +if(_8){ +for(var i=0;i<_8.length;i++){ +try{ +if(Prado.Focus.canFocusOn(_8[i])){ +return _8[i]; +}else{ +var _10=Prado.Focus.findTarget(_8[i]); +if(_10){ +return _10; +} +} +} +catch(e){ +} +} +} +return null; +}; +Prado.Focus.isVisible=function(_11){ +var _12=_11; +while((typeof (_12)!="undefined")&&(_12!=null)){ +if(_12.disabled||(typeof (_12.style)!="undefined"&&((typeof (_12.style.display)!="undefined"&&_12.style.display=="none")||(typeof (_12.style.visibility)!="undefined"&&_12.style.visibility=="hidden")))){ +return false; +} +if(typeof (_12.parentNode)!="undefined"&&_12.parentNode!=null&&_12.parentNode!=_12&&_12.parentNode.tagName.toLowerCase()!="body"){ +_12=_12.parentNode; +}else{ +return true; +} +} +return true; +}; + + diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 0e3ad773..6c9d6ce8 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -36,7 +36,7 @@ class TClientScriptManager extends TComponent const SCRIPT_DIR='Web/Javascripts/js'; const POSTBACK_FUNC='Prado.PostBack.perform'; const POSTBACK_OPTIONS='Prado.PostBack.Options'; - private $_owner; + private $_page; private $_hiddenFields=array(); private $_beginScripts=array(); private $_endScripts=array(); @@ -51,7 +51,7 @@ class TClientScriptManager extends TComponent public function __construct(TPage $owner) { - $this->_owner=$owner; + $this->_page=$owner; } public function getPostBackEventReference($control,$parameter='',$options=null,$javascriptPrefix=true) @@ -78,7 +78,7 @@ class TClientScriptManager extends TComponent if($options->ActionUrl!=='') { $flag=true; - $this->_owner->setCrossPagePostBack(true); + $this->_page->setCrossPagePostBack(true); $opt.='"'.THttpUtility::quoteJavaScriptString($options->ActionUrl).'",'; } else @@ -104,7 +104,7 @@ class TClientScriptManager extends TComponent else $opt='null'; $this->registerPostBackScript(); - $formID=$this->_owner->getForm()->getUniqueID(); + $formID=$this->_page->getForm()->getUniqueID(); $postback=self::POSTBACK_FUNC.'(\''.$formID.'\',\''.$control->getUniqueID().'\',\''.THttpUtility::quoteJavaScriptString($parameter).'\','.$opt.')'; if($options && $options->AutoPostBack) $postback='setTimeout(\''.THttpUtility::quoteJavaScriptString($postback).'\',0)'; @@ -126,7 +126,7 @@ class TClientScriptManager extends TComponent { if(!isset($this->_publishedScriptFiles[$jsFile])) { - $am=$this->_owner->getService()->getAssetManager(); + $am=$this->_page->getService()->getAssetManager(); $this->_publishedScriptFiles[$jsFile]=$am->publishFilePath(Prado::getFrameworkPath().'/'.self::SCRIPT_DIR.'/'.$jsFile); } return $this->_publishedScriptFiles[$jsFile]; @@ -147,12 +147,9 @@ class TClientScriptManager extends TComponent if(!$this->_scrollScriptRegistered) { $this->_scrollScriptRegistered=true; - $this->registerHiddenField(TPage::FIELD_SCROLL_X,$this->_owner->getScrollPositionX()); - $this->registerHiddenField(TPage::FIELD_SCROLL_Y,$this->_owner->getScrollPositionY()); - /* - this.ClientScript.RegisterStartupScript(typeof(Page), "PageScrollPositionScript", "\r\ntheForm.oldSubmit = theForm.submit;\r\ntheForm.submit = WebForm_SaveScrollPositionSubmit;\r\n\r\ntheForm.oldOnSubmit = theForm.onsubmit;\r\ntheForm.onsubmit = WebForm_SaveScrollPositionOnSubmit;\r\n" + (this.IsPostBack ? "\r\ntheForm.oldOnLoad = window.onload;\r\nwindow.onload = WebForm_RestoreScrollPosition;\r\n" : string.Empty), true); - need base.js - */ + $this->registerHiddenField(TPage::FIELD_SCROLL_X,$x); + $this->registerHiddenField(TPage::FIELD_SCROLL_Y,$y); + // TBD, need scroll.js } } diff --git a/framework/Web/UI/TForm.php b/framework/Web/UI/TForm.php index 0edb976b..4c619299 100644 --- a/framework/Web/UI/TForm.php +++ b/framework/Web/UI/TForm.php @@ -19,6 +19,7 @@ class TForm extends TControl $attributes->remove('action'); $page=$this->getPage(); + /* $onsubmit=$page->getClientOnSubmitEvent(); if($onsubmit!=='') { @@ -29,7 +30,7 @@ class TForm extends TControl } if($page->getClientSupportsJavaScript()) $writer->addAttribute('onsubmit',$onsubmit); - } + }*/ if($this->getDefaultButton()!=='') {//todo $control=$this->findControl($this->getDefaultButton()); diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 42f495cf..46d1d8df 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -1,8 +1,13 @@ _inFormRender=false; } + /** + * Sets input focus on a control after the page is rendered to users. + * @param TControl control to receive focus + */ public function setFocus(TControl $value) { $this->_focusedControl=$value; } + /** + * @return boolean (TBD) whether to keep the page scroll position the same as users last see it + */ public function getMaintainScrollPosition() { return $this->_maintainScrollPosition; } + /** + * @param boolean (TBD) whether to keep the page scroll position the same as users last see it + */ public function setMaintainScrollPosition($value) { $this->_maintainScrollPosition=TPropertyValue::ensureBoolean($value); @@ -723,38 +738,9 @@ class TPage extends TTemplateControl return true; } - - public function getClientOnSubmitEvent() - { - // todo - if($this->getClientScript()->getHasSubmitStatements()) - return 'javascript:return WebForm_OnSubmit();'; - else - return ''; - } - protected function initializeCulture() { } - - /** - * @internal - */ - public function loadScrollPosition() - { - if($this->_previousPagePath==='' && $this->_requestValueCollection) - { - if(isset($_REQUEST['__SCROLLPOSITIONX'])) - $this->_scrollPositionX=(integer)$_REQUEST['__SCROLLPOSITIONX']; - if(isset($_REQUEST['__SCROLLPOSITIONY'])) - $this->_scrollPositionX=(integer)$_REQUEST['__SCROLLPOSITIONY']; - } - } - - - final public function registerAsyncTask() - { - } } ?> \ No newline at end of file diff --git a/framework/Web/UI/TPostBackOptions.php b/framework/Web/UI/TPostBackOptions.php deleted file mode 100644 index b39d5675..00000000 --- a/framework/Web/UI/TPostBackOptions.php +++ /dev/null @@ -1,34 +0,0 @@ -ActionUrl=$actionUrl; - $this->Argument=$argument; - $this->AutoPostBack=$autoPostBack; - $this->ClientSubmit=$clientSubmit; - $this->PerformValidation=$performValidation; - $this->TargetControl=$targetControl; - $this->TrackFocus=$trackFocus; - $this->ValidationGroup=$validationGroup; - } -} - -?> \ No newline at end of file -- cgit v1.2.3