diff options
author | wei <> | 2006-10-21 04:08:47 +0000 |
---|---|---|
committer | wei <> | 2006-10-21 04:08:47 +0000 |
commit | f52b02f003b2e0da75d737fa3c0622def2242af5 (patch) | |
tree | a2c28eb3a1e80d35952bb060e0c93901644a0d8e | |
parent | 2cde8e5fdc97489c0dae5e3f8acf6036229ec343 (diff) |
remove prado ajax code.
-rw-r--r-- | framework/Web/Javascripts/js/compressed/ajax.js | 134 | ||||
-rw-r--r-- | framework/Web/Javascripts/js/debug/ajax.js | 967 |
2 files changed, 2 insertions, 1099 deletions
diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js index f39f8325..53c34dca 100644 --- a/framework/Web/Javascripts/js/compressed/ajax.js +++ b/framework/Web/Javascripts/js/compressed/ajax.js @@ -20,112 +20,7 @@ this.transport=Ajax.getTransport();this.setOptions(options);var onComplete=this. response=response.stripScripts();if(receiver){if(this.options.insertion){new this.options.insertion(receiver,response);}else{Element.update(receiver,response);}} if(this.responseIsSuccess()){if(this.onComplete) setTimeout(this.onComplete.bind(this),10);}}});Ajax.PeriodicalUpdater=Class.create();Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(container,url,options){this.setOptions(options);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=container;this.url=url;this.start();},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent();},stop:function(){this.updater.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments);},updateComplete:function(request){if(this.options.decay){this.decay=(request.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=request.responseText;} -this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options);}});Prado.AJAX={Service:'Prototype'};Prado.AJAX.EvalScript=function(output) -{var match=new RegExp(Ajax.Updater.ScriptFragment,'img');var scripts=output.match(match);if(scripts) -{match=new RegExp(Ajax.Updater.ScriptFragment,'im');setTimeout((function() -{for(var i=0;i<scripts.length;i++) -eval(scripts[i].match(match)[1]);}).bind(this),50);}} -Prado.AJAX.Request=Class.create();Prado.AJAX.Request.prototype=Object.extend(Ajax.Request.prototype,{evalJSON:function() -{try -{var json=this.transport.getResponseHeader('X-JSON'),object;object=eval(json);return object;} -catch(e) -{if(isString(json)) -{return Prado.AJAX.JSON.parse(json);}}},respondToReadyState:function(readyState){var event=Ajax.Request.Events[readyState];var transport=this.transport,json=this.evalJSON();if(event=='Complete'&&transport.status) -Ajax.Responders.dispatch('on'+transport.status,this,transport,json);(this.options['on'+event]||Prototype.emptyFunction)(transport,json);Ajax.Responders.dispatch('on'+event,this,transport,json);if(event=='Complete') -(this.options['on'+this.transport.status]||this.options['on'+(this.responseIsSuccess()?'Success':'Failure')]||Prototype.emptyFunction)(transport,json);if(event=='Complete') -this.transport.onreadystatechange=Prototype.emptyFunction;}});Prado.AJAX.Error=function(e,code) -{e.name='Prado.AJAX.Error';e.code=code;return e;} -Prado.AJAX.RequestBuilder=Class.create();Prado.AJAX.RequestBuilder.prototype={initialize:function() -{this.body='';this.data=[];},encode:function(data) -{return Prado.AJAX.JSON.stringify(data);},build:function(data) -{var sep='';for(var argName in data) -{if(isFunction(data[argName]))continue;try -{this.body+=sep+argName+'=';this.body+=encodeURIComponent(this.encode(data[argName]));}catch(e){throw Prado.AJAX.Error(e,1006);} -sep='&';}},getAll:function() -{this.build(this.data);return this.body;}} -Prado.AJAX.RemoteObject=function(){};Prado.AJAX.RemoteObject.Request=Class.create();Prado.AJAX.RemoteObject.Request.prototype=Object.extend(Prado.AJAX.Request.prototype,{initialize:function(options) -{this.transport=Ajax.getTransport();this.setOptions(options);this.post=new Prado.AJAX.RequestBuilder();},invokeRemoteObject:function(url,args) -{this.initParameters(args);this.options.postBody=this.post.getAll();this.request(url);},initParameters:function(args) -{this.post.data['__parameters']=[];for(var i=0;i<args.length;i++) -this.post.data['__parameters'][i]=args[i];}});Prado.AJAX.RemoteObject.prototype={baseInitialize:function(handlers,options) -{this.__handlers=handlers||{};this.__service=new Prado.AJAX.RemoteObject.Request(options);},__call:function(url,method,args) -{this.__service.options.onSuccess=this.__onSuccess.bind(this);this.__callback=method;return this.__service.invokeRemoteObject(url+"/"+method,args);},__onSuccess:function(transport,json) -{if(this.__handlers[this.__callback]) -this.__handlers[this.__callback](json,transport.responseText);}};Prado.AJAX.Exception={"on505":function(request,transport,e) -{var msg='HTTP '+transport.status+" with response";Logger.error(msg,transport.responseText);Logger.exception(e);},onComplete:function(request,transport,e) -{if(transport.status!=505) -{var msg='HTTP '+transport.status+" with response : \n";msg+=transport.responseText+"\n";msg+="Data : \n"+inspect(e);Logger.warn(msg);}},format:function(e) -{var msg=e.type+" with message \""+e.message+"\"";msg+=" in "+e.file+"("+e.line+")\n";msg+="Stack trace:\n";var trace=e.trace;for(var i=0;i<trace.length;i++) -{msg+=" #"+i+" "+trace[i].file;msg+="("+trace[i].line+"): ";msg+=trace[i]["class"]+"->"+trace[i]["function"]+"()"+"\n";} -return msg;},logException:function(e) -{var msg=Prado.AJAX.Exception.format(e);Logger.error("Server Error "+e.code,msg);}} -Event.OnLoad(function() -{if(typeof Logger!="undefined") -{Logger.exception=Prado.AJAX.Exception.logException;Ajax.Responders.register(Prado.AJAX.Exception);}});Prado.AJAX.Callback=Class.create();Prado.AJAX.Callback.prototype=Object.extend(new Prado.AJAX.RemoteObject(),{initialize:function(ID,options) -{if(!isString(ID)&&typeof(ID.id)!="undefined") -ID=ID.id;if(!isString(ID)) -throw new Error('A Control ID must be specified');this.baseInitialize(this,options);this.options=options||[];this.__service.post.data['__ID']=ID;this.requestCallback();},collectPostData:function() -{var IDs=Prado.AJAX.Callback.IDs;this.__service.post.data['__data']={};for(var i=0;i<IDs.length;i++) -{var id=IDs[i];if(id.indexOf("[]")>-1) -this.__service.post.data['__data'][id]=this.collectArrayPostData(id);else if(isObject($(id))) -this.__service.post.data['__data'][id]=$F(id);}},collectArrayPostData:function(name) -{var elements=document.getElementsByName(name);var data=[];$A(elements).each(function(el) -{if($F(el))data.push($F(el));});return data;},requestCallback:function() -{this.collectPostData();if(Prado.AJAX.Validate(this.options)) -return this.__call(Prado.AJAX.Callback.Server,'handleCallback',this.options.params);},handleCallback:function(result,output) -{if(typeof(result)!="undefined"&&!isNull(result)) -{this.options.onSuccess(result['data'],output);if(result['actions']) -result.actions.each(Prado.AJAX.Callback.Action.__run);}}});Prado.AJAX.Callback.Action={__run:function(command) -{for(var name in command) -{if(command[name][0]&&($(command[name][0])||command[name][0].indexOf("[]")>-1)) -{name.toFunction().apply(this,command[name]);}}}};Prado.AJAX.Validate=function(options) -{if(options.CausesValidation) -{if(options.ValidatorGroup) -return Prado.Validation.ValidateValidatorGroup(options.ValidatorGroup);else if(options.ValidationGroup) -return Prado.Validation.ValidateValidationGroup(options.ValidationGroup);else -return Prado.Validation.ValidateNonGroup(options.ValidationForm);} -else -return true;};Prado.AJAX.Callback.Server='';Prado.AJAX.Callback.IDs=[];Prado.Callback=function(ID,params,onSuccess,options) -{var callback={'params':[params]||[],'onSuccess':onSuccess||Prototype.emptyFunction,'CausesValidation':true};Object.extend(callback,options||{});new Prado.AJAX.Callback(ID,callback);return false;} -Array.prototype.______array='______array';Prado.AJAX.JSON={org:'http://www.JSON.org',copyright:'(c)2005 JSON.org',license:'http://www.crockford.com/JSON/license.html',stringify:function(arg){var c,i,l,s='',v;switch(typeof arg){case'object':if(arg){if(arg.______array=='______array'){for(i=0;i<arg.length;++i){v=this.stringify(arg[i]);if(s){s+=',';} -s+=v;} -return'['+s+']';}else if(typeof arg.toString!='undefined'){for(i in arg){v=arg[i];if(typeof v!='undefined'&&typeof v!='function'){v=this.stringify(v);if(s){s+=',';} -s+=this.stringify(i)+':'+v;}} -return'{'+s+'}';}} -return'null';case'number':return isFinite(arg)?String(arg):'null';case'string':l=arg.length;s='"';for(i=0;i<l;i+=1){c=arg.charAt(i);if(c>=' '){if(c=='\\'||c=='"'){s+='\\';} -s+=c;}else{switch(c){case'\b':s+='\\b';break;case'\f':s+='\\f';break;case'\n':s+='\\n';break;case'\r':s+='\\r';break;case'\t':s+='\\t';break;default:c=c.charCodeAt();s+='\\u00'+Math.floor(c/16).toString(16)+ -(c%16).toString(16);}}} -return s+'"';case'boolean':return String(arg);default:return'null';}},parse:function(text){var at=0;var ch=' ';function error(m){throw{name:'JSONError',message:m,at:at-1,text:text};} -function next(){ch=text.charAt(at);at+=1;return ch;} -function white(){while(ch){if(ch<=' '){next();}else if(ch=='/'){switch(next()){case'/':while(next()&&ch!='\n'&&ch!='\r'){} -break;case'*':next();for(;;){if(ch){if(ch=='*'){if(next()=='/'){next();break;}}else{next();}}else{error("Unterminated comment");}} -break;default:error("Syntax error");}}else{break;}}} -function string(){var i,s='',t,u;if(ch=='"'){outer:while(next()){if(ch=='"'){next();return s;}else if(ch=='\\'){switch(next()){case'b':s+='\b';break;case'f':s+='\f';break;case'n':s+='\n';break;case'r':s+='\r';break;case't':s+='\t';break;case'u':u=0;for(i=0;i<4;i+=1){t=parseInt(next(),16);if(!isFinite(t)){break outer;} -u=u*16+t;} -s+=String.fromCharCode(u);break;default:s+=ch;}}else{s+=ch;}}} -error("Bad string");} -function array(){var a=[];if(ch=='['){next();white();if(ch==']'){next();return a;} -while(ch){a.push(value());white();if(ch==']'){next();return a;}else if(ch!=','){break;} -next();white();}} -error("Bad array");} -function object(){var k,o={};if(ch=='{'){next();white();if(ch=='}'){next();return o;} -while(ch){k=string();white();if(ch!=':'){break;} -next();o[k]=value();white();if(ch=='}'){next();return o;}else if(ch!=','){break;} -next();white();}} -error("Bad object");} -function number(){var n='',v;if(ch=='-'){n='-';next();} -while(ch>='0'&&ch<='9'){n+=ch;next();} -if(ch=='.'){n+='.';while(next()&&ch>='0'&&ch<='9'){n+=ch;}} -if(ch=='e'||ch=='E'){n+='e';next();if(ch=='-'||ch=='+'){n+=ch;next();} -while(ch>='0'&&ch<='9'){n+=ch;next();}} -v=+n;if(!isFinite(v)){}else{return v;}} -function word(){switch(ch){case't':if(next()=='r'&&next()=='u'&&next()=='e'){next();return true;} -break;case'f':if(next()=='a'&&next()=='l'&&next()=='s'&&next()=='e'){next();return false;} -break;case'n':if(next()=='u'&&next()=='l'&&next()=='l'){next();return null;} -break;} -error("Syntax error");} -function value(){white();switch(ch){case'{':return object();case'[':return array();case'"':return string();case'-':return number();default:return ch>='0'&&ch<='9'?number():word();}} -return value();}};if(typeof Effect=='undefined') +this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options);}});if(typeof Effect=='undefined') throw("controls.js requires including script.aculo.us' effects.js library");var Autocompleter={} Autocompleter.Base=function(){};Autocompleter.Base.prototype={baseInitialize:function(element,update,options){this.element=$(element);this.update=$(update);this.hasFocus=false;this.changed=false;this.active=false;this.index=0;this.entryCount=0;if(this.setOptions) this.setOptions(options);else @@ -271,29 +166,4 @@ handle=handle.parentNode;this.activeHandle=handle;this.activeHandleIdx=this.hand Event.stop(event);}},update:function(event){if(this.active){if(!this.dragging)this.dragging=true;this.draw(event);if(navigator.appVersion.indexOf('AppleWebKit')>0)window.scrollBy(0,0);Event.stop(event);}},draw:function(event){var pointer=[Event.pointerX(event),Event.pointerY(event)];var offsets=Position.cumulativeOffset(this.track);pointer[0]-=this.offsetX+offsets[0];pointer[1]-=this.offsetY+offsets[1];this.event=event;this.setValue(this.translateToValue(this.isVertical()?pointer[1]:pointer[0]));if(this.initialized&&this.options.onSlide) this.options.onSlide(this.values.length>1?this.values:this.value,this);},endDrag:function(event){if(this.active&&this.dragging){this.finishDrag(event,true);Event.stop(event);} this.active=false;this.dragging=false;},finishDrag:function(event,success){this.active=false;this.dragging=false;this.updateFinished();},updateFinished:function(){if(this.initialized&&this.options.onChange) -this.options.onChange(this.values.length>1?this.values:this.value,this);this.event=null;}} -Prado.AutoCompleter=Class.create();Prado.AutoCompleter.Base=function(){};Prado.AutoCompleter.Base.prototype=Object.extend(Autocompleter.Base.prototype,{updateElement:function(selectedElement) -{if(this.options.updateElement){this.options.updateElement(selectedElement);return;} -var value=Element.collectTextNodesIgnoreClass(selectedElement,'informal');var lastTokenPos=this.findLastToken();if(lastTokenPos!=-1){var newValue=this.element.value.substr(0,lastTokenPos+1);var whitespace=this.element.value.substr(lastTokenPos+1).match(/^\s+/);if(whitespace) -newValue+=whitespace[0];this.element.value=(newValue+value).trim();}else{this.element.value=value.trim();} -this.element.focus();if(this.options.afterUpdateElement) -this.options.afterUpdateElement(this.element,selectedElement);}});Prado.AutoCompleter.prototype=Object.extend(new Autocompleter.Base(),{initialize:function(element,update,options) -{this.baseInitialize(element,update,options);},onUpdateReturn:function(result) -{if(isString(result)&&result.length>0) -this.updateChoices(result);},getUpdatedChoices:function() -{Prado.Callback(this.element.id,this.getToken(),this.onUpdateReturn.bind(this));}});Prado.ActivePanel={callbacks:{},register:function(id,options) -{Prado.ActivePanel.callbacks[id]=options;},update:function(id,param) -{var request=new Prado.ActivePanel.Request(id,Prado.ActivePanel.callbacks[id]);request.callback(param);}} -Prado.ActivePanel.Request=Class.create();Prado.ActivePanel.Request.prototype={initialize:function(element,options) -{this.element=element;this.setOptions(options);},setOptions:function(options) -{this.options={onSuccess:this.onSuccess.bind(this)} -Object.extend(this.options,options||{});},callback:function(param) -{this.options.params=[param];new Prado.AJAX.Callback(this.element,this.options);},onSuccess:function(result,output) -{if(this.options.update) -{if(!this.options.evalScripts) -output=output.stripScripts();Element.update(this.options.update,output);}}} -Prado.DropContainer=Class.create();Prado.DropContainer.prototype=Object.extend(new Prado.ActivePanel.Request(),{initialize:function(element,options) -{this.element=element;this.setOptions(options);Object.extend(this.options,{onDrop:this.onDrop.bind(this),evalScripts:true,onSuccess:options.onSuccess||this.onSuccess.bind(this)});Droppables.add(element,this.options);},onDrop:function(draggable,droppable) -{this.callback(draggable.id)}});Prado.ActiveImageButton=Class.create();Prado.ActiveImageButton.prototype={initialize:function(element,options) -{this.element=$(element);this.options=options;Event.observe(this.element,"click",this.click.bind(this));},click:function(e) -{var el=$('{$this->ClientID}');var imagePos=Position.cumulativeOffset(this.element);var clickedPos=[e.clientX,e.clientY];var param=(clickedPos[0]-imagePos[0]+1)+","+(clickedPos[1]-imagePos[1]+1);Prado.Callback(this.element,param,null,this.options);Event.stop(e);}}
\ No newline at end of file +this.options.onChange(this.values.length>1?this.values:this.value,this);this.event=null;}}
\ No newline at end of file diff --git a/framework/Web/Javascripts/js/debug/ajax.js b/framework/Web/Javascripts/js/debug/ajax.js index 9a61cabb..44ace8cc 100644 --- a/framework/Web/Javascripts/js/debug/ajax.js +++ b/framework/Web/Javascripts/js/debug/ajax.js @@ -286,775 +286,6 @@ Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), { }); -/**
- * Prado AJAX service. The default service provider is JPSpan.
- */
-Prado.AJAX = { Service : 'Prototype' };
-
-/**
- * Parse and execute javascript embedded in html.
- */
-Prado.AJAX.EvalScript = function(output)
-{
-
- var match = new RegExp(Ajax.Updater.ScriptFragment, 'img');
- var scripts = output.match(match);
- if (scripts)
- {
- match = new RegExp(Ajax.Updater.ScriptFragment, 'im');
- setTimeout((function()
- {
- for (var i = 0; i < scripts.length; i++)
- eval(scripts[i].match(match)[1]);
- }).bind(this), 50);
- }
-}
-
-
-/**
- * AJAX service request using Prototype's AJAX request class.
- */
-Prado.AJAX.Request = Class.create();
-Prado.AJAX.Request.prototype = Object.extend(Ajax.Request.prototype,
-{
- /**
- * Evaluate the respond JSON data, override parent implementing.
- * If default eval fails, try parsing the JSON data (slower).
- */
- evalJSON: function()
- {
- try
- {
- var json = this.transport.getResponseHeader('X-JSON'), object;
- object = eval(json);
- return object;
- }
- catch (e)
- {
- if(isString(json))
- {
- return Prado.AJAX.JSON.parse(json);
- }
- }
- },
-
- respondToReadyState: function(readyState) {
- var event = Ajax.Request.Events[readyState];
- var transport = this.transport, json = this.evalJSON();
-
-
- if(event == 'Complete' && transport.status)
- Ajax.Responders.dispatch('on' + transport.status, this, transport, json);
-
- (this.options['on' + event] || Prototype.emptyFunction)(transport, json);
- Ajax.Responders.dispatch('on' + event, this, transport, json);
-
- if (event == 'Complete')
- (this.options['on' + this.transport.status]
- || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
- || Prototype.emptyFunction)(transport, json);
-
-
- /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
- if (event == 'Complete')
- this.transport.onreadystatechange = Prototype.emptyFunction;
- }
-
-});
-
-Prado.AJAX.Error = function(e, code)
-{
- e.name = 'Prado.AJAX.Error';
- e.code = code;
- return e;
-}
-
-/**
- * Post data builder, serialize the data using JSON.
- */
-Prado.AJAX.RequestBuilder = Class.create();
-Prado.AJAX.RequestBuilder.prototype =
-{
- initialize : function()
- {
- this.body = '';
- this.data = [];
- },
- encode : function(data)
- {
- return Prado.AJAX.JSON.stringify(data);
- },
- build : function(data)
- {
- var sep = '';
- for ( var argName in data)
- {
- if(isFunction(data[argName])) continue;
- try
- {
- this.body += sep + argName + '=';
- this.body += encodeURIComponent(this.encode(data[argName]));
- } catch (e) {
- throw Prado.AJAX.Error(e, 1006);
- }
- sep = '&';
- }
- },
-
- getAll : function()
- {
- this.build(this.data);
- return this.body;
- }
-}
-
-
-Prado.AJAX.RemoteObject = function(){};
-
-/**
- * AJAX service request for Prado RemoteObjects
- */
-Prado.AJAX.RemoteObject.Request = Class.create();
-Prado.AJAX.RemoteObject.Request.prototype = Object.extend(Prado.AJAX.Request.prototype,
-{
- /**
- * Initialize the RemoteObject Request, overrides parent
- * implementation by delaying the request to invokeRemoteObject.
- */
- initialize : function(options)
- {
- this.transport = Ajax.getTransport();
- this.setOptions(options);
- this.post = new Prado.AJAX.RequestBuilder();
- },
-
- /**
- * Call the remote object,
- * @param string the remote server url
- * @param array additional arguments
- */
- invokeRemoteObject : function(url, args)
- {
- this.initParameters(args);
- this.options.postBody = this.post.getAll();
- this.request(url);
- },
-
- /**
- * Set the additional arguments as post data with key '__parameters'
- */
- initParameters : function(args)
- {
- this.post.data['__parameters'] = [];
- for(var i = 0; i<args.length; i++)
- this.post.data['__parameters'][i] = args[i];
- }
-});
-
-/**
- * Base proxy class for Prado RemoteObjects via AJAX.
- * e.g.
- * <code>
- * var TestObject1 = Class.create();
- * TestObject1.prototype = Object.extend(new Prado.AJAX.RemoteObject(),
- * {
- * initialize : function(handlers, options)
- * {
- * this.__serverurl = 'http://127.0.0.1/.....';
- * this.baseInitialize(handlers, options);
- * }
- *
- * method1 : function()
- * {
- * return this.__call(this.__serverurl, 'method1', arguments);
- * }
- * });
- *</code>
- * And client usage,
- * <code>
- * var test1 = new TestObject1(); //create new remote object
- * test1.method1(); //call the method, no onComplete hook
- *
- * var onComplete = { method1 : function(result){ alert(result) } };
- * //create new remote object with onComplete callback
- * var test2 = new TestObject1(onComplete);
- * test2.method1(); //call it, on success, onComplete's method1 is called.
- * </code>
- */
-Prado.AJAX.RemoteObject.prototype =
-{
- baseInitialize : function(handlers, options)
- {
- this.__handlers = handlers || {};
- this.__service = new Prado.AJAX.RemoteObject.Request(options);
- },
-
- __call : function(url, method, args)
- {
- this.__service.options.onSuccess = this.__onSuccess.bind(this);
- this.__callback = method;
- return this.__service.invokeRemoteObject(url+"/"+method, args);
- },
-
- __onSuccess : function(transport, json)
- {
- if(this.__handlers[this.__callback])
- this.__handlers[this.__callback](json, transport.responseText);
- }
-};
-
-/**
- * Respond to Prado AJAX request exceptions.
- */
-Prado.AJAX.Exception =
-{
- /**
- * Server returns 505 exception. Just log it.
- */
- "on505" : function(request, transport, e)
- {
- var msg = 'HTTP '+transport.status+" with response";
- Logger.error(msg, transport.responseText);
- Logger.exception(e);
- },
-
- onComplete : function(request, transport, e)
- {
- if(transport.status != 505)
- {
- var msg = 'HTTP '+transport.status+" with response : \n";
- msg += transport.responseText + "\n";
- msg += "Data : \n"+inspect(e);
- Logger.warn(msg);
- }
- },
-
- format : function(e)
- {
- var msg = e.type + " with message \""+e.message+"\"";
- msg += " in "+e.file+"("+e.line+")\n";
- msg += "Stack trace:\n";
- var trace = e.trace;
- for(var i = 0; i<trace.length; i++)
- {
- msg += " #"+i+" "+trace[i].file;
- msg += "("+trace[i].line+"): ";
- msg += trace[i]["class"]+"->"+trace[i]["function"]+"()"+"\n";
- }
- return msg;
- },
-
- logException : function(e)
- {
- var msg = Prado.AJAX.Exception.format(e);
- Logger.error("Server Error "+e.code, msg);
- }
-}
-
-//Add HTTP exception respones when logger is enabled.
-Event.OnLoad(function()
-{
- if(typeof Logger != "undefined")
- {
- Logger.exception = Prado.AJAX.Exception.logException;
- Ajax.Responders.register(Prado.AJAX.Exception);
- }
-});
-
-/**
- * Prado Callback service that provides component intergration,
- * viewstate (read only), and automatic form data serialization.
- * Usage: <code>new Prado.AJAX.Callback('MyPage.MyComponentID.raiseCallbackEvent', options)</code>
- * These classes should be called by the components developers.
- * For inline callback service, use <t>Prado.Callback(callbackID, params)</t>.
- */
-Prado.AJAX.Callback = Class.create();
-Prado.AJAX.Callback.prototype = Object.extend(new Prado.AJAX.RemoteObject(),
-{
-
- /**
- * Create and request a new Prado callback service.
- * @param string|element the callback ID, must be of the form, <t>ClassName.ComponentID.MethodName</t>
- * @param list options with list key onCallbackReturn, and more.
- *
- */
- initialize : function(ID, options)
- {
- if(!isString(ID) && typeof(ID.id) != "undefined")
- ID = ID.id;
- if(!isString(ID))
- throw new Error('A Control ID must be specified');
- this.baseInitialize(this, options);
- this.options = options || [];
- this.__service.post.data['__ID'] = ID;
- this.requestCallback();
- },
-
- /**
- * Get form data for components that implements IPostBackHandler.
- */
- collectPostData : function()
- {
- var IDs = Prado.AJAX.Callback.IDs;
- this.__service.post.data['__data'] = {};
- for(var i = 0; i<IDs.length; i++)
- {
- var id = IDs[i];
- if(id.indexOf("[]") > -1)
- this.__service.post.data['__data'][id] =
- this.collectArrayPostData(id);
- else if(isObject($(id)))
- this.__service.post.data['__data'][id] = $F(id);
- }
- },
-
- collectArrayPostData : function(name)
- {
- var elements = document.getElementsByName(name);
- var data = [];
- $A(elements).each(function(el)
- {
- if($F(el)) data.push($F(el));
- });
- return data;
- },
-
- /**
- * Prepares and calls the AJAX request.
- * Collects the data from components that implements IPostBackHandler
- * and the viewstate as part of the request payload.
- */
- requestCallback : function()
- {
- this.collectPostData();
- if(Prado.AJAX.Validate(this.options))
- return this.__call(Prado.AJAX.Callback.Server, 'handleCallback', this.options.params);
- },
-
- /**
- * On callback request return, call the onSuccess function.
- */
- handleCallback : function(result, output)
- {
- if(typeof(result) != "undefined" && !isNull(result))
- {
- this.options.onSuccess(result['data'], output);
- if(result['actions'])
- result.actions.each(Prado.AJAX.Callback.Action.__run);
- }
- }
-});
-
-/**
- * Prase and evaluate Callback clien-side actions.
- */
-Prado.AJAX.Callback.Action =
-{
- __run : function(command)
- {
- for(var name in command)
- {
- //first parameter must be a valid element or begins with '@'
- if(command[name][0] && ($(command[name][0]) || command[name][0].indexOf("[]") > -1))
- {
- name.toFunction().apply(this,command[name]);
- }
- }
- }
-};
-
-
-/**
- * Returns false if validation required and validates to false,
- * returns true otherwise.
- * @return boolean true if validation passes.
- */
-Prado.AJAX.Validate = function(options)
-{
- if(options.CausesValidation)
- {
- if(options.ValidatorGroup)
- return Prado.Validation.ValidateValidatorGroup(options.ValidatorGroup);
- else if(options.ValidationGroup)
- return Prado.Validation.ValidateValidationGroup(options.ValidationGroup);
- else
- return Prado.Validation.ValidateNonGroup(options.ValidationForm);
- }
- else
- return true;
-};
-
-
-//Available callback service
-Prado.AJAX.Callback.Server = '';
-
-//List of IDs that implements IPostBackHandler
-Prado.AJAX.Callback.IDs = [];
-
-/**
- * Simple AJAX callback interface, suitable for inline javascript.
- * e.g., <code><a href="..." onclick="Prado.Callback('..', 'Hello');">Click me</a></code>
- * @param {String} callback ID
- * @param {Array} parameters to pass to the callback service
- * @param {Function} on callback success handler method
- * @param {Object} additional callback options
- */
-Prado.Callback = function(ID, params, onSuccess, options)
-{
- var callback =
- {
- 'params' : [params] || [],
- 'onSuccess' : onSuccess || Prototype.emptyFunction,
- 'CausesValidation' : true
- };
-
- Object.extend(callback, options || {});
-
- new Prado.AJAX.Callback(ID, callback);
- return false;
-} - -/*
-Copyright (c) 2005 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-Array.prototype.______array = '______array';
-
-Prado.AJAX.JSON = {
- org: 'http://www.JSON.org',
- copyright: '(c)2005 JSON.org',
- license: 'http://www.crockford.com/JSON/license.html',
-
- stringify: function (arg) {
- var c, i, l, s = '', v;
-
- switch (typeof arg) {
- case 'object':
- if (arg) {
- if (arg.______array == '______array') {
- for (i = 0; i < arg.length; ++i) {
- v = this.stringify(arg[i]);
- if (s) {
- s += ',';
- }
- s += v;
- }
- return '[' + s + ']';
- } else if (typeof arg.toString != 'undefined') {
- for (i in arg) {
- v = arg[i];
- if (typeof v != 'undefined' && typeof v != 'function') {
- v = this.stringify(v);
- if (s) {
- s += ',';
- }
- s += this.stringify(i) + ':' + v;
- }
- }
- return '{' + s + '}';
- }
- }
- return 'null';
- case 'number':
- return isFinite(arg) ? String(arg) : 'null';
- case 'string':
- l = arg.length;
- s = '"';
- for (i = 0; i < l; i += 1) {
- c = arg.charAt(i);
- if (c >= ' ') {
- if (c == '\\' || c == '"') {
- s += '\\';
- }
- s += c;
- } else {
- switch (c) {
- case '\b':
- s += '\\b';
- break;
- case '\f':
- s += '\\f';
- break;
- case '\n':
- s += '\\n';
- break;
- case '\r':
- s += '\\r';
- break;
- case '\t':
- s += '\\t';
- break;
- default:
- c = c.charCodeAt();
- s += '\\u00' + Math.floor(c / 16).toString(16) +
- (c % 16).toString(16);
- }
- }
- }
- return s + '"';
- case 'boolean':
- return String(arg);
- default:
- return 'null';
- }
- },
- parse: function (text) {
- var at = 0;
- var ch = ' ';
-
- function error(m) {
- throw {
- name: 'JSONError',
- message: m,
- at: at - 1,
- text: text
- };
- }
-
- function next() {
- ch = text.charAt(at);
- at += 1;
- return ch;
- }
-
- function white() {
- while (ch) {
- if (ch <= ' ') {
- next();
- } else if (ch == '/') {
- switch (next()) {
- case '/':
- while (next() && ch != '\n' && ch != '\r') {}
- break;
- case '*':
- next();
- for (;;) {
- if (ch) {
- if (ch == '*') {
- if (next() == '/') {
- next();
- break;
- }
- } else {
- next();
- }
- } else {
- error("Unterminated comment");
- }
- }
- break;
- default:
- error("Syntax error");
- }
- } else {
- break;
- }
- }
- }
-
- function string() {
- var i, s = '', t, u;
-
- if (ch == '"') {
-outer: while (next()) {
- if (ch == '"') {
- next();
- return s;
- } else if (ch == '\\') {
- switch (next()) {
- case 'b':
- s += '\b';
- break;
- case 'f':
- s += '\f';
- break;
- case 'n':
- s += '\n';
- break;
- case 'r':
- s += '\r';
- break;
- case 't':
- s += '\t';
- break;
- case 'u':
- u = 0;
- for (i = 0; i < 4; i += 1) {
- t = parseInt(next(), 16);
- if (!isFinite(t)) {
- break outer;
- }
- u = u * 16 + t;
- }
- s += String.fromCharCode(u);
- break;
- default:
- s += ch;
- }
- } else {
- s += ch;
- }
- }
- }
- error("Bad string");
- }
-
- function array() {
- var a = [];
-
- if (ch == '[') {
- next();
- white();
- if (ch == ']') {
- next();
- return a;
- }
- while (ch) {
- a.push(value());
- white();
- if (ch == ']') {
- next();
- return a;
- } else if (ch != ',') {
- break;
- }
- next();
- white();
- }
- }
- error("Bad array");
- }
-
- function object() {
- var k, o = {};
-
- if (ch == '{') {
- next();
- white();
- if (ch == '}') {
- next();
- return o;
- }
- while (ch) {
- k = string();
- white();
- if (ch != ':') {
- break;
- }
- next();
- o[k] = value();
- white();
- if (ch == '}') {
- next();
- return o;
- } else if (ch != ',') {
- break;
- }
- next();
- white();
- }
- }
- error("Bad object");
- }
-
- function number() {
- var n = '', v;
- if (ch == '-') {
- n = '-';
- next();
- }
- while (ch >= '0' && ch <= '9') {
- n += ch;
- next();
- }
- if (ch == '.') {
- n += '.';
- while (next() && ch >= '0' && ch <= '9') {
- n += ch;
- }
- }
- if (ch == 'e' || ch == 'E') {
- n += 'e';
- next();
- if (ch == '-' || ch == '+') {
- n += ch;
- next();
- }
- while (ch >= '0' && ch <= '9') {
- n += ch;
- next();
- }
- }
- v = +n;
- if (!isFinite(v)) {
- ////error("Bad number");
- } else {
- return v;
- }
- }
-
- function word() {
- switch (ch) {
- case 't':
- if (next() == 'r' && next() == 'u' && next() == 'e') {
- next();
- return true;
- }
- break;
- case 'f':
- if (next() == 'a' && next() == 'l' && next() == 's' &&
- next() == 'e') {
- next();
- return false;
- }
- break;
- case 'n':
- if (next() == 'u' && next() == 'l' && next() == 'l') {
- next();
- return null;
- }
- break;
- }
- error("Syntax error");
- }
-
- function value() {
- white();
- switch (ch) {
- case '{':
- return object();
- case '[':
- return array();
- case '"':
- return string();
- case '-':
- return number();
- default:
- return ch >= '0' && ch <= '9' ? number() : word();
- }
- }
-
- return value();
- }
-}; - // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) // (c) 2005 Jon Tirsen (http://www.tirsen.com) @@ -3103,201 +2334,3 @@ Control.Slider.prototype = { } } -/**
- * Auto complete textbox via AJAX.
- */
-Prado.AutoCompleter = Class.create();
-
-
-/**
- * Overrides parent implementation of updateElement by trimming the value.
- */
-Prado.AutoCompleter.Base = function(){};
-Prado.AutoCompleter.Base.prototype = Object.extend(Autocompleter.Base.prototype,
-{
- updateElement: function(selectedElement)
- {
- if (this.options.updateElement) {
- this.options.updateElement(selectedElement);
- return;
- }
-
- var value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
- var lastTokenPos = this.findLastToken();
- if (lastTokenPos != -1) {
- var newValue = this.element.value.substr(0, lastTokenPos + 1);
- var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/);
- if (whitespace)
- newValue += whitespace[0];
- this.element.value = (newValue + value).trim();
- } else {
- this.element.value = value.trim();
- }
- this.element.focus();
-
- if (this.options.afterUpdateElement)
- this.options.afterUpdateElement(this.element, selectedElement);
- }
-});
-
-/**
- * Based on the Prototype Autocompleter class.
- * This client-side component should be instantiated from a Prado component.
- * Usage: <t>new Prado.AutoCompleter('textboxID', 'updateDivID', {callbackID : '...'});
- */
-Prado.AutoCompleter.prototype = Object.extend(new Autocompleter.Base(),
-{
- /**
- * This component is initialized by
- * <code>new Prado.AutoCompleter(...)</code>
- * @param string the ID of the textbox element to observe
- * @param string the ID of the div to display the auto-complete options
- * @param array a hash of options, e.g. auto-completion token separator.
- */
- initialize : function(element, update, options)
- {
- this.baseInitialize(element, update, options);
- },
-
- /**
- * The callback function, i.e., function called on successful AJAX return.
- * Calls update choices in the Autocompleter.
- * @param string new auto-complete options for display
- */
- onUpdateReturn : function(result)
- {
- if(isString(result) && result.length > 0)
- this.updateChoices(result);
- },
-
- /**
- * Requesting new choices using Prado's client-side callback scheme.
- */
- getUpdatedChoices : function()
- {
- Prado.Callback(this.element.id, this.getToken(), this.onUpdateReturn.bind(this));
- }
-});
-
-/**
- * Prado TActivePanel client javascript. Usage
- * <code>
- * Prado.ActivePanel.register("id", options);
- * Prado.ActivePanel.update("id", "hello");
- * </code>
- */
-Prado.ActivePanel =
-{
- callbacks : {},
-
- register : function(id, options)
- {
- Prado.ActivePanel.callbacks[id] = options;
- },
-
- update : function(id, param)
- {
- var request = new Prado.ActivePanel.Request(id,
- Prado.ActivePanel.callbacks[id]);
- request.callback(param);
- }
-}
-
-/**
- * Client-script for TActivePanel. Uses Callback to notify the server
- * for updates, if update option is set, the innerHTML of the update ID
- * is set to the returned output.
- */
-Prado.ActivePanel.Request = Class.create();
-Prado.ActivePanel.Request.prototype =
-{
- initialize : function(element, options)
- {
- this.element = element;
- this.setOptions(options);
- },
-
- /**
- * Set some options.
- */
- setOptions : function(options)
- {
- this.options =
- {
- onSuccess : this.onSuccess.bind(this)
- }
- Object.extend(this.options, options || {});
- },
-
- /**
- * Make the callback request
- */
- callback : function(param)
- {
- this.options.params = [param];
- new Prado.AJAX.Callback(this.element, this.options);
- },
-
- /**
- * Callback onSuccess handler, update the element innerHTML if necessary
- */
- onSuccess : function(result, output)
- {
- if(this.options.update)
- {
- if (!this.options.evalScripts)
- output = output.stripScripts();
- Element.update(this.options.update, output);
- }
- }
-}
-
-/**
- * Drop container to accept draggable component drops.
- */
-Prado.DropContainer = Class.create();
-Prado.DropContainer.prototype = Object.extend(new Prado.ActivePanel.Request(),
-{
- initialize : function(element, options)
- {
- this.element = element;
- this.setOptions(options);
- Object.extend(this.options,
- {
- onDrop : this.onDrop.bind(this),
- evalScripts : true,
- onSuccess : options.onSuccess || this.onSuccess.bind(this)
- });
- Droppables.add(element, this.options);
- },
-
- onDrop : function(draggable, droppable)
- {
- this.callback(draggable.id)
- }
-});
-
-Prado.ActiveImageButton = Class.create();
-Prado.ActiveImageButton.prototype =
-{
- initialize : function(element, options)
- {
- this.element = $(element);
- this.options = options;
- Event.observe(this.element, "click", this.click.bind(this));
- },
-
- click : function(e)
- {
- var el = $('{$this->ClientID}');
- var imagePos = Position.cumulativeOffset(this.element);
- var clickedPos = [e.clientX, e.clientY];
- var param = (clickedPos[0]-imagePos[0]+1)+","+(clickedPos[1]-imagePos[1]+1);
- Prado.Callback(this.element, param, null, this.options);
- Event.stop(e);
- }
-}
-
-
- - |