summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2005-12-04 17:51:05 +0000
committerxue <>2005-12-04 17:51:05 +0000
commit418baf36d477bcbdd6fb4eaf4037ea6a2d93f21c (patch)
treeef74701133d6f33d47c8c47ca85782e36cb7746e
parent0dda82c2a13ed09a2520dda9b420e8f90703c67b (diff)
-rw-r--r--.gitattributes3
-rw-r--r--framework/Web/Javascripts/WebForms.js298
-rw-r--r--framework/Web/Javascripts/js/base.js966
-rw-r--r--framework/Web/UI/TClientScriptManager.php19
-rw-r--r--framework/Web/UI/TForm.php3
-rw-r--r--framework/Web/UI/TPage.php50
-rw-r--r--framework/Web/UI/TPostBackOptions.php34
7 files changed, 995 insertions, 378 deletions
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;i<arguments.length;i++){
+this[_1+i]=arguments[i];
+}
+return this.length;
+};
+}
+if(!Function.prototype.apply){
+Function.prototype.apply=function(_3,_4){
+var _5=new Array();
+if(!_3){
+_3=window;
+}
+if(!_4){
+_4=new Array();
+}
+for(var i=0;i<_4.length;i++){
+_5[i]="parameters["+i+"]";
+}
+_3.__apply__=this;
+var _6=eval("object.__apply__("+_5.join(", ")+")");
+_3.__apply__=null;
+return _6;
+};
+}
+
+var Class={create:function(){
+return function(){
+this.initialize.apply(this,arguments);
+};
+}};
+var Abstract=new Object();
+Object.extend=function(_1,_2){
+for(property in _2){
+_1[property]=_2[property];
+}
+return _1;
+};
+Object.inspect=function(_3){
+try{
+if(_3==undefined){
+return "undefined";
+}
+if(_3==null){
+return "null";
+}
+return _3.inspect?_3.inspect():_3.toString();
+}
+catch(e){
+if(e instanceof RangeError){
+return "...";
+}
+throw e;
+}
+};
+Function.prototype.bind=function(_4){
+var _5=this;
+return function(){
+return _5.apply(_4,arguments);
+};
+};
+Function.prototype.bindAsEventListener=function(_6){
+var _7=this;
+return function(_8){
+return _7.call(_6,_8||window.event);
+};
+};
+Object.extend(Number.prototype,{toColorPart:function(){
+var _9=this.toString(16);
+if(this<16){
+return "0"+_9;
+}
+return _9;
+},succ:function(){
+return this+1;
+},times:function(_10){
+$R(0,this,true).each(_10);
+return this;
+}});
+var Try={these:function(){
+var _11;
+for(var i=0;i<arguments.length;i++){
+var _13=arguments[i];
+try{
+_11=_13();
+break;
+}
+catch(e){
+}
+}
+return _11;
+}};
+var PeriodicalExecuter=Class.create();
+PeriodicalExecuter.prototype={initialize:function(_14,_15){
+this.callback=_14;
+this.frequency=_15;
+this.currentlyExecuting=false;
+this.registerCallback();
+},registerCallback:function(){
+setInterval(this.onTimerEvent.bind(this),this.frequency*1000);
+},onTimerEvent:function(){
+if(!this.currentlyExecuting){
+try{
+this.currentlyExecuting=true;
+this.callback();
+}
+finally{
+this.currentlyExecuting=false;
+}
+}
+}};
+function $(){
+var _16=new Array();
+for(var i=0;i<arguments.length;i++){
+var _17=arguments[i];
+if(typeof _17=="string"){
+_17=document.getElementById(_17);
+}
+if(arguments.length==1){
+return _17;
+}
+_16.push(_17);
+}
+return _16;
+}
+
+function isElement(o,_2){
+return o&&isObject(o)&&((!_2&&(o==window||o==document))||o.nodeType==1);
+}
+function $(n,d){
+if(isElement(n)){
+return n;
+}
+if(isString(n)==false){
+return null;
+}
+var p,i,x;
+if(!d){
+d=document;
+}
+if((p=n.indexOf("?"))>0&&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<d.forms.length;i++){
+x=d.forms[i][n];
+}
+for(i=0;!x&&d.layers&&i<d.layers.length;i++){
+x=DOM.find(n,d.layers[i].document);
+}
+if(!x&&d.getElementById){
+x=d.getElementById(n);
+}
+return x;
+}
+
+function isAlien(a){
+return isObject(a)&&typeof a.constructor!="function";
+}
+function isArray(a){
+return isObject(a)&&a.constructor==Array;
+}
+function isBoolean(a){
+return typeof a=="boolean";
+}
+function isFunction(a){
+return typeof a=="function";
+}
+function isNull(a){
+return typeof a=="object"&&!a;
+}
+function isNumber(a){
+return typeof a=="number"&&isFinite(a);
+}
+function isObject(a){
+return (a&&typeof a=="object")||isFunction(a);
+}
+function isRegexp(a){
+return a&&a.constructor==RegExp;
+}
+function isString(a){
+return typeof a=="string";
+}
+function isUndefined(a){
+return typeof a=="undefined";
+}
+function isEmpty(o){
+var i,v;
+if(isObject(o)){
+for(i in o){
+v=o[i];
+if(isUndefined(v)&&isFunction(v)){
+return false;
+}
+}
+}
+return true;
+}
+function undef(v){
+return isUndefined(v);
+}
+function isdef(v){
+return !isUndefined(v);
+}
+function isElement(o,_5){
+return o&&isObject(o)&&((!_5&&(o==window||o==document))||o.nodeType==1);
+}
+function isList(o){
+return o&&isObject(o)&&(isArray(o)||o.item);
+}
+
+Object.extend(String.prototype,{stripTags:function(){
+return this.replace(/<\/?[^>]+>/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<len;i++){
+var s=_8[i];
+_9+=s.charAt(0).toUpperCase()+s.substring(1);
+}
+return _9;
+},inspect:function(){
+return "'"+this.replace("\\","\\\\").replace("'","\\'")+"'";
+}});
+String.prototype.parseQuery=String.prototype.toQueryParams;
+
+Object.extend(String.prototype,{pad:function(_1,_2,_3){
+if(!_3){
+_3=" ";
+}
+var s=this;
+var _5=_1.toLowerCase()=="left";
+while(s.length<_2){
+s=_5?_3+s:s+_3;
+}
+return s;
+},padLeft:function(_6,_7){
+return this.pad("left",_6,_7);
+},padRight:function(_8,_9){
+return this.pad("right",_8,_9);
+},zerofill:function(len){
+var s=this;
+var ix=/^[+-]/.test(s)?1:0;
+while(s.length<len){
+s=s.insert(ix,"0");
+}
+return s;
+},trim:function(){
+return this.replace(/^\s+|\s+$/g,"");
+},trimLeft:function(){
+return this.replace(/^\s+/,"");
+},trimRight:function(){
+return this.replace(/\s+$/,"");
+}});
+
+var $break=new Object();
+var $continue=new Object();
+var Enumerable={each:function(_1){
+var _2=0;
+try{
+this._each(function(_3){
+try{
+_1(_3,_2++);
+}
+catch(e){
+if(e!=$continue){
+throw e;
+}
+}
+});
+}
+catch(e){
+if(e!=$break){
+throw e;
+}
+}
+},all:function(_4){
+var _5=true;
+this.each(function(_6,_7){
+if(!(_5&=(_4||Prototype.K)(_6,_7))){
+throw $break;
+}
+});
+return _5;
+},any:function(_8){
+var _9=true;
+this.each(function(_10,_11){
+if(_9&=(_8||Prototype.K)(_10,_11)){
+throw $break;
+}
+});
+return _9;
+},collect:function(_12){
+var _13=[];
+this.each(function(_14,_15){
+_13.push(_12(_14,_15));
+});
+return _13;
+},detect:function(_16){
+var _17;
+this.each(function(_18,_19){
+if(_16(_18,_19)){
+_17=_18;
+throw $break;
+}
+});
+return _17;
+},findAll:function(_20){
+var _21=[];
+this.each(function(_22,_23){
+if(_20(_22,_23)){
+_21.push(_22);
+}
+});
+return _21;
+},grep:function(_24,_25){
+var _26=[];
+this.each(function(_27,_28){
+var _29=_27.toString();
+if(_29.match(_24)){
+_26.push((_25||Prototype.K)(_27,_28));
+}
+});
+return _26;
+},include:function(_30){
+var _31=false;
+this.each(function(_32){
+if(_32==_30){
+_31=true;
+throw $break;
+}
+});
+return _31;
+},inject:function(_33,_34){
+this.each(function(_35,_36){
+_33=_34(_33,_35,_36);
+});
+return _33;
+},invoke:function(_37){
+var _38=$A(arguments).slice(1);
+return this.collect(function(_39){
+return _39[_37].apply(_39,_38);
+});
+},max:function(_40){
+var _41;
+this.each(function(_42,_43){
+_42=(_40||Prototype.K)(_42,_43);
+if(_42>=(_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 a<b?-1:a>b?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 "#<Enumerable:"+this.toArray().inspect()+">";
+}};
+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;i<this.length;i++){
+_4(this[i]);
+}
+},first:function(){
+return this[0];
+},last:function(){
+return this[this.length-1];
+},compact:function(){
+return this.select(function(_5){
+return _5!=undefined||_5!=null;
+});
+},flatten:function(){
+return this.inject([],function(_6,_7){
+return _6.concat(_7.constructor==Array?_7.flatten():[_7]);
+});
+},without:function(){
+var _8=$A(arguments);
+return this.select(function(_9){
+return !_8.include(_9);
+});
+},indexOf:function(_10){
+for(var i=0;i<this.length;i++){
+if(this[i]==_10){
+return i;
+}
+}
+return false;
+},reverse:function(){
+var _11=[];
+for(var i=this.length;i>0;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;i<this.length;i++){
+var _5=this[i];
+if(_3?_5===_1:isRegexp(_1)?_1.test(_5):isFunction(_1)?_1(_5):_5==_1){
+return i;
+}
+}
+return -1;
+};
+Array.prototype.find=function(_6,_7,_8){
+var i=this.indexOf(_6,_7,_8);
+if(i!=-1){
+return this[i];
+}
+return null;
+};
+Array.prototype.contains=function(_9,_10){
+return this.indexOf(_9,0,_10)!==-1;
+};
+Array.prototype.has=Array.prototype.contains;
+Array.prototype.include=Array.prototype.contains;
+Array.prototype.count=function(_11,_12){
+var pos,start=0,count=0;
+while((pos=this.indexOf(_11,start,_12))!==-1){
+start=pos+1;
+count++;
+}
+return count;
+};
+Array.prototype.remove=function(_14,all,_16){
+while(this.contains(_14,_16)){
+this.splice(this.indexOf(_14,0,_16),1);
+if(!all){
+break;
+}
+}
+return this;
+};
+Array.prototype.merge=function(){
+var a=[];
+for(var i=0;i<arguments.length;i++){
+for(var j=0;j<arguments[i].length;j++){
+a.push(arguments[i][j]);
+}
+}
+for(var i=0;i<a.length;i++){
+this.push(a[i]);
+}
+return this;
+};
+Array.prototype.min=function(){
+if(!this.length){
+return;
+}
+var n=this[0];
+for(var i=1;i<this.length;i++){
+if(n>this[i]){
+n=this[i];
+}
+}
+return n;
+};
+Array.prototype.max=function(){
+if(!this.length){
+return;
+}
+var n=this[0];
+for(var i=1;i<this.length;i++){
+if(n<this[i]){
+n=this[i];
+}
+}
+return n;
+};
+Array.prototype.first=function(){
+return this[0];
+};
+Array.prototype.last=function(){
+return this[this.length-1];
+};
+Array.prototype.sjoin=function(){
+return this.join(" ");
+};
+Array.prototype.njoin=function(){
+return this.join("\n");
+};
+Array.prototype.cjoin=function(){
+return this.join(", ");
+};
+Array.prototype.equals=function(a,_20){
+if(this==a){
+return true;
+}
+if(a.length!=this.length){
+return false;
+}
+return this.map(function(_21,idx){
+return _20?_21===a[idx]:_21==a[idx];
+}).all();
+};
+Array.prototype.all=function(fn){
+return filter(this,fn).length==this.length;
+};
+Array.prototype.any=function(fn){
+return filter(this,fn).length>0;
+};
+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 "#<Hash:{"+this.map(function(_8){
+return _8.map(Object.inspect).join(": ");
+}).join(", ")+"}>";
+}};
+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(_6<this.start){
+return false;
+}
+if(this.exclusive){
+return _6<this.end;
+}
+return _6<=this.end;
+}});
+var $R=function(_7,_8,_9){
+return new Range(_7,_8,_9);
+};
+
+function __strfn(_1,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(_1.split(/\s*,\s*/),quote).join()+","+quote(fn)+")");
+}
+function each(_4,fn){
+if(typeof (fn)=="string"){
+return each(_4,__strfn("item,idx,list",fn));
+}
+for(var i=0;i<_4.length;i++){
+fn(_4[i],i,_4);
+}
+}
+function map(_6,fn){
+if(typeof (fn)=="string"){
+return map(_6,__strfn("item,idx,list",fn));
+}
+var _7=[];
+fn=fn||function(v){
+return v;
+};
+for(var i=0;i<_6.length;i++){
+_7.push(fn(_6[i],i,_6));
+}
+return _7;
+}
+
+Prado=Class.create();
+Prado.version="3.0a";
+
+Prado.PostBack=Class.create();
+Prado.PostBack.Options=Class.create();
+Prado.PostBack.Options.prototype={initialize:function(_1,_2,_3,_4,_5){
+this.performValidation=_1;
+this.validationGroup=_2;
+this.actionUrl=_3;
+this.trackFocus=_4;
+this.clientSubmit=_5;
+}};
+Prado.PostBack.perform=function(_6,_7,_8,_9){
+var _10=document.getElementById?document.getElementById(_6):document.forms[_6];
+var _11=true;
+if((typeof (_9)!="undefined")||_9==null){
+if(_9.performValidation){
+_11=Prado.Validation.validate(_9.validationGroup);
+}
+if(_11){
+if((typeof (_9.actionUrl)!="undefined")&&(_9.actionUrl!=null)&&(_9.actionUrl.length>0)){
+_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 @@
<?php
-Prado::using('System.Web.UI.*');
+//Prado::using('System.Web.UI.*');
Prado::using('System.Web.UI.WebControls.*');
+Prado::using('System.Web.UI.TControl');
+Prado::using('System.Web.UI.TTemplateControl');
+Prado::using('System.Web.UI.TForm');
+Prado::using('System.Web.UI.TClientScriptManager');
+//Prado::using('System.Web
class TPage extends TTemplateControl
{
const FIELD_POSTBACK_TARGET='PRADO_POSTBACK_TARGET';
@@ -662,7 +667,7 @@ class TPage extends TTemplateControl
}
/**
- * @internal
+ * @internal This method is invoked by TForm at the beginning of its rendering
*/
public function beginFormRender($writer)
{
@@ -674,7 +679,7 @@ class TPage extends TTemplateControl
}
/**
- * @internal
+ * @internal This method is invoked by TForm at the end of its rendering
*/
public function endFormRender($writer)
{
@@ -702,16 +707,26 @@ class TPage extends TTemplateControl
$this->_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 @@
-<?php
-
-class TPostBackOptions extends TComponent
-{
- public $ActionUrl;
- public $Argument;
- public $AutoPostBack;
- public $ClientSubmit;
- public $PerformValidation;
- public $TargetControl;
- public $TrackFocus;
- public $ValidationGroup;
-
- public function __construct($targetControl=null,
- $argument='',
- $actionUrl='',
- $autoPostBack=false,
- $trackFocus=false,
- $clientSubmit=true,
- $performValidation=false,
- $validationGroup='')
- {
- $this->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