diff -r bd5069e1f19a -r c7d737202d59 includes/clientside/static/SpryData.js --- a/includes/clientside/static/SpryData.js Sun Aug 17 23:24:41 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1045 +0,0 @@ -// SpryData.js - version 0.45 - Spry Pre-Release 1.6.1 -// -// Copyright (c) 2007. Adobe Systems Incorporated. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of Adobe Systems Incorporated nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -var Spry;if(!Spry)Spry={};if(!Spry.Utils)Spry.Utils={};Spry.Utils.msProgIDs=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0"];Spry.Utils.createXMLHttpRequest=function() -{var req=null;try -{if(window.ActiveXObject) -{while(!req&&Spry.Utils.msProgIDs.length) -{try{req=new ActiveXObject(Spry.Utils.msProgIDs[0]);}catch(e){req=null;} -if(!req) -Spry.Utils.msProgIDs.splice(0,1);}} -if(!req&&window.XMLHttpRequest) -req=new XMLHttpRequest();} -catch(e){req=null;} -if(!req) -Spry.Debug.reportError("Failed to create an XMLHttpRequest object!");return req;};Spry.Utils.loadURL=function(method,url,async,callback,opts) -{var req=new Spry.Utils.loadURL.Request();req.method=method;req.url=url;req.async=async;req.successCallback=callback;Spry.Utils.setOptions(req,opts);try -{req.xhRequest=Spry.Utils.createXMLHttpRequest();if(!req.xhRequest) -return null;if(req.async) -req.xhRequest.onreadystatechange=function(){Spry.Utils.loadURL.callback(req);};req.xhRequest.open(req.method,req.url,req.async,req.username,req.password);if(req.headers) -{for(var name in req.headers) -req.xhRequest.setRequestHeader(name,req.headers[name]);} -req.xhRequest.send(req.postData);if(!req.async) -Spry.Utils.loadURL.callback(req);} -catch(e) -{if(req.errorCallback) -req.errorCallback(req);else -Spry.Debug.reportError("Exception caught while loading "+url+": "+e);req=null;} -return req;};Spry.Utils.loadURL.callback=function(req) -{if(!req||req.xhRequest.readyState!=4) -return;if(req.successCallback&&(req.xhRequest.status==200||req.xhRequest.status==0)) -req.successCallback(req);else if(req.errorCallback) -req.errorCallback(req);};Spry.Utils.loadURL.Request=function() -{var props=Spry.Utils.loadURL.Request.props;var numProps=props.length;for(var i=0;i]*>[\s\r\n]*(<\!--)?|(-->)?[\s\r\n]*<\/script>/img,"");Spry.Utils.eval(s);}}};Spry.Utils.updateContent=function(ele,url,finishFunc,opts) -{Spry.Utils.loadURL("GET",url,true,function(req) -{Spry.Utils.setInnerHTML(ele,req.xhRequest.responseText);if(finishFunc) -finishFunc(ele,url);},opts);};if(!Spry.$$) -{Spry.Utils.addEventListener=function(element,eventType,handler,capture) -{try -{element=Spry.$(element);if(element.addEventListener) -element.addEventListener(eventType,handler,capture);else if(element.attachEvent) -element.attachEvent("on"+eventType,handler);} -catch(e){}};Spry.Utils.removeEventListener=function(element,eventType,handler,capture) -{try -{element=Spry.$(element);if(element.removeEventListener) -element.removeEventListener(eventType,handler,capture);else if(element.detachEvent) -element.detachEvent("on"+eventType,handler);} -catch(e){}};Spry.Utils.addLoadListener=function(handler) -{if(typeof window.addEventListener!='undefined') -window.addEventListener('load',handler,false);else if(typeof document.addEventListener!='undefined') -document.addEventListener('load',handler,false);else if(typeof window.attachEvent!='undefined') -window.attachEvent('onload',handler);};Spry.Utils.addClassName=function(ele,className) -{ele=Spry.$(ele);if(!ele||!className||(ele.className&&ele.className.search(new RegExp("\\b"+className+"\\b"))!=-1)) -return;ele.className+=(ele.className?" ":"")+className;};Spry.Utils.removeClassName=function(ele,className) -{ele=Spry.$(ele);if(!ele||!className||(ele.className&&ele.className.search(new RegExp("\\b"+className+"\\b"))==-1)) -return;ele.className=ele.className.replace(new RegExp("\\s*\\b"+className+"\\b","g"),"");};Spry.Utils.getObjectByName=function(name) -{var result=null;if(name) -{var lu=window;var objPath=name.split(".");for(var i=0;lu&&i1) -{for(var i=0,elements=[],length=arguments.length;i"]/)!=-1) -{str=str.replace(/&/g,"&");str=str.replace(//g,">");str=str.replace(/"/g,""");} -return str};Spry.Utils.decodeEntities=function(str) -{var d=Spry.Utils.decodeEntities.div;if(!d) -{d=document.createElement('div');Spry.Utils.decodeEntities.div=d;if(!d)return str;} -d.innerHTML=str;if(d.childNodes.length==1&&d.firstChild.nodeType==3&&d.firstChild.nextSibling==null) -str=d.firstChild.data;else -{str=str.replace(/</gi,"<");str=str.replace(/>/gi,">");str=str.replace(/"/gi,"\"");str=str.replace(/&/gi,"&");} -return str;};Spry.Utils.fixupIETagAttributes=function(inStr) -{var outStr="";var tagStart=inStr.match(/^<[^\s>]+\s*/)[0];var tagEnd=inStr.match(/\s*\/?>$/)[0];var tagAttrs=inStr.replace(/^<[^\s>]+\s*|\s*\/?>/g,"");outStr+=tagStart;if(tagAttrs) -{var startIndex=0;var endIndex=0;while(startIndex=tagAttrs.length) -{outStr+=tagAttrs.substring(startIndex,endIndex);break;} -++endIndex;outStr+=tagAttrs.substring(startIndex,endIndex);startIndex=endIndex;if(tagAttrs.charAt(endIndex)=='"'||tagAttrs.charAt(endIndex)=="'") -{var savedIndex=endIndex++;while(endIndex]*>|-->|\\]\\](>|\>)","g");var searchStartIndex=0;var skipFixUp=0;while(inStr.length) -{var results=regexp.exec(inStr);if(!results||!results[0]) -{outStr+=inStr.substr(searchStartIndex,inStr.length-searchStartIndex);break;} -if(results.index!=searchStartIndex) -{outStr+=inStr.substr(searchStartIndex,results.index-searchStartIndex);} -if(results[0]==""||results[0]=="]]>"||(skipFixUp&&results[0]=="]]>")) -{--skipFixUp;outStr+=results[0];} -else if(!skipFixUp&&results[0].charAt(0)=='<') -outStr+=Spry.Utils.fixupIETagAttributes(results[0]);else -outStr+=results[0];searchStartIndex=regexp.lastIndex;} -return outStr;};Spry.Utils.stringToXMLDoc=function(str) -{var xmlDoc=null;try -{var xmlDOMObj=new ActiveXObject("Microsoft.XMLDOM");xmlDOMObj.async=false;xmlDOMObj.loadXML(str);xmlDoc=xmlDOMObj;} -catch(e) -{try -{var domParser=new DOMParser;xmlDoc=domParser.parseFromString(str,'text/xml');} -catch(e) -{Spry.Debug.reportError("Caught exception in Spry.Utils.stringToXMLDoc(): "+e+"\n");xmlDoc=null;}} -return xmlDoc;};Spry.Utils.serializeObject=function(obj) -{var str="";var firstItem=true;if(obj==null||obj==undefined) -return str+obj;var objType=typeof obj;if(objType=="number"||objType=="boolean") -str+=obj;else if(objType=="string") -str+="\""+Spry.Utils.escapeQuotesAndLineBreaks(obj)+"\"";else if(obj.constructor==Array) -{str+="[";for(var i=0;i0) -{node=nodeStack.pop();if(node==root) -node=null;else -try{node=node.nextSibling;}catch(e){node=null;}}} -if(nodeStack&&nodeStack.length>0) -Spry.Debug.trace("-- WARNING: Spry.Utils.getNodesByFunc() failed to traverse all nodes!\n");return resultArr;};Spry.Utils.getFirstChildWithNodeName=function(node,nodeName) -{var child=node.firstChild;while(child) -{if(child.nodeName==nodeName) -return child;child=child.nextSibling;} -return null;};Spry.Utils.setOptions=function(obj,optionsObj,ignoreUndefinedProps) -{if(!optionsObj) -return;for(var optionName in optionsObj) -{if(ignoreUndefinedProps&&optionsObj[optionName]==undefined) -continue;obj[optionName]=optionsObj[optionName];}};Spry.Utils.SelectionManager={};Spry.Utils.SelectionManager.selectionGroups=new Object;Spry.Utils.SelectionManager.SelectionGroup=function() -{this.selectedElements=new Array;};Spry.Utils.SelectionManager.SelectionGroup.prototype.select=function(element,className,multiSelect) -{var selObj=null;if(!multiSelect) -{this.clearSelection();} -else -{for(var i=0;i
"+Spry.Utils.encodeEntities(parent.innerHTML)+"
");return false;} -parent=parent.parentNode;}} -if(attr.value) -{attr=node.attributes.getNamedItem("id");if(!attr||!attr.value) -{node.setAttribute("id","spryregion"+(++Spry.Data.initRegions.nextUniqueRegionID));} -lastRegionFound=node;return true;} -else -Spry.Debug.reportError(attrName+" attributes require one or more data set names as values!");}} -catch(e){} -return false;});var name,dataSets,i;var newRegions=[];for(i=0;iPerforming IE innerHTML fix up of Region: "+name+"

"+Spry.Utils.encodeEntities(dataStr));dataStr=Spry.Utils.fixUpIEInnerHTML(dataStr);} -if(Spry.Data.Region.debug) -Spry.Debug.trace("
Region template markup for '"+name+"':

"+Spry.Utils.encodeEntities(dataStr));if(!hasSpryContent) -{rgn.innerHTML="";} -var region=new Spry.Data.Region(rgn,name,isDetailRegion,dataStr,dataSets,regionStates,regionStateMap,hasBehaviorAttributes);Spry.Data.regionsArray[region.name]=region;newRegions.push(region);} -for(var i=0;i0) -this.curRowID=this.data[0]['ds_RowID'];else -this.curRowID=0;};Spry.Data.DataSet.prototype.cancelLoadData=function() -{if(this.pendingRequest&&this.pendingRequest.timer) -clearTimeout(this.pendingRequest.timer);this.pendingRequest=null;};Spry.Data.DataSet.prototype.getRowCount=function(unfiltered) -{var rows=this.getData(unfiltered);return rows?rows.length:0;};Spry.Data.DataSet.prototype.getRowByID=function(rowID) -{if(!this.data) -return null;return this.dataHash[rowID];};Spry.Data.DataSet.prototype.getRowByRowNumber=function(rowNumber,unfiltered) -{var rows=this.getData(unfiltered);if(rows&&rowNumber>=0&&rowNumber=this.data.length) -{Spry.Debug.trace("Invalid row number: "+rowNumber+"\n");return;} -var rowID=this.data[rowNumber]["ds_RowID"];if(rowID==undefined||this.curRowID==rowID) -return;this.setCurrentRow(rowID);};Spry.Data.DataSet.prototype.findRowsWithColumnValues=function(valueObj,firstMatchOnly,unfiltered) -{var results=[];var rows=this.getData(unfiltered);if(rows) -{var numRows=rows.length;for(var i=0;i0)?this.lastSortColumns[0]:"";};Spry.Data.DataSet.prototype.getSortOrder=function(){return this.lastSortOrder?this.lastSortOrder:"";};Spry.Data.DataSet.prototype.sort=function(columnNames,sortOrder) -{if(!columnNames) -return;if(typeof columnNames=="string") -columnNames=[columnNames,"ds_RowID"];else if(columnNames.length<2&&columnNames[0]!="ds_RowID") -columnNames.push("ds_RowID");if(!sortOrder) -sortOrder="toggle";if(sortOrder=="toggle") -{if(this.lastSortColumns.length>0&&this.lastSortColumns[0]==columnNames[0]&&this.lastSortOrder=="ascending") -sortOrder="descending";else -sortOrder="ascending";} -if(sortOrder!="ascending"&&sortOrder!="descending") -{Spry.Debug.reportError("Invalid sort order type specified: "+sortOrder+"\n");return;} -var nData={oldSortColumns:this.lastSortColumns,oldSortOrder:this.lastSortOrder,newSortColumns:columnNames,newSortOrder:sortOrder};this.notifyObservers("onPreSort",nData);var cname=columnNames[columnNames.length-1];var sortfunc=Spry.Data.DataSet.prototype.sort.getSortFunc(cname,this.getColumnType(cname),sortOrder);for(var i=columnNames.length-2;i>=0;i--) -{cname=columnNames[i];sortfunc=Spry.Data.DataSet.prototype.sort.buildSecondarySortFunc(Spry.Data.DataSet.prototype.sort.getSortFunc(cname,this.getColumnType(cname),sortOrder),sortfunc);} -if(this.unfilteredData) -{this.unfilteredData.sort(sortfunc);if(this.filterFunc) -this.filter(this.filterFunc,true);} -else -this.data.sort(sortfunc);this.lastSortColumns=columnNames.slice(0);this.lastSortOrder=sortOrder;this.notifyObservers("onPostSort",nData);};Spry.Data.DataSet.prototype.sort.getSortFunc=function(prop,type,order) -{var sortfunc=null;if(type=="number") -{if(order=="ascending") -sortfunc=function(a,b) -{a=a[prop];b=b[prop];if(a==undefined||b==undefined) -return(a==b)?0:(a?1:-1);return a-b;};else -sortfunc=function(a,b) -{a=a[prop];b=b[prop];if(a==undefined||b==undefined) -return(a==b)?0:(a?-1:1);return b-a;};} -else if(type=="date") -{if(order=="ascending") -sortfunc=function(a,b) -{var dA=a[prop];var dB=b[prop];dA=dA?(new Date(dA)):0;dB=dB?(new Date(dB)):0;return dA-dB;};else -sortfunc=function(a,b) -{var dA=a[prop];var dB=b[prop];dA=dA?(new Date(dA)):0;dB=dB?(new Date(dB)):0;return dB-dA;};} -else -{if(order=="ascending") -sortfunc=function(a,b){a=a[prop];b=b[prop];if(a==undefined||b==undefined) -return(a==b)?0:(a?1:-1);var tA=a.toString();var tB=b.toString();var tA_l=tA.toLowerCase();var tB_l=tB.toLowerCase();var min_len=tA.length>tB.length?tB.length:tA.length;for(var i=0;ib_l_c) -return 1;else if(a_l_cb_c) -return 1;else if(a_ctB.length) -return 1;return-1;};else -sortfunc=function(a,b){a=a[prop];b=b[prop];if(a==undefined||b==undefined) -return(a==b)?0:(a?-1:1);var tA=a.toString();var tB=b.toString();var tA_l=tA.toLowerCase();var tB_l=tB.toLowerCase();var min_len=tA.length>tB.length?tB.length:tA.length;for(var i=0;ib_l_c) -return-1;else if(a_l_cb_c) -return-1;else if(a_ctB.length) -return-1;return 1;};} -return sortfunc;};Spry.Data.DataSet.prototype.sort.buildSecondarySortFunc=function(funcA,funcB) -{return function(a,b) -{var ret=funcA(a,b);if(ret==0) -ret=funcB(a,b);return ret;};};Spry.Data.DataSet.prototype.filterData=function(filterFunc,filterOnly) -{var dataChanged=false;if(!filterFunc) -{this.filterDataFunc=null;dataChanged=true;} -else -{this.filterDataFunc=filterFunc;if(this.dataWasLoaded&&((this.unfilteredData&&this.unfilteredData.length)||(this.data&&this.data.length))) -{if(this.unfilteredData) -{this.data=this.unfilteredData;this.unfilteredData=null;} -var oldData=this.data;this.data=[];this.dataHash={};for(var i=0;i0) -{var self=this;this.loadInterval=interval;this.loadIntervalID=setInterval(function(){self.loadData();},interval);}};Spry.Data.DataSet.prototype.stopLoadInterval=function() -{if(this.loadIntervalID) -clearInterval(this.loadIntervalID);this.loadInterval=0;this.loadIntervalID=null;};Spry.Data.DataSet.nextDataSetID=0;Spry.Data.HTTPSourceDataSet=function(dataSetURL,dataSetOptions) -{Spry.Data.DataSet.call(this);this.url=dataSetURL;this.dataSetsForDataRefStrings=new Array;this.hasDataRefStrings=false;this.useCache=true;this.setRequestInfo(dataSetOptions,true);Spry.Utils.setOptions(this,dataSetOptions,true);this.recalculateDataSetDependencies();if(this.loadInterval>0) -this.startLoadInterval(this.loadInterval);};Spry.Data.HTTPSourceDataSet.prototype=new Spry.Data.DataSet();Spry.Data.HTTPSourceDataSet.prototype.constructor=Spry.Data.HTTPSourceDataSet;Spry.Data.HTTPSourceDataSet.prototype.setRequestInfo=function(requestInfo,undefineRequestProps) -{this.requestInfo=new Spry.Utils.loadURL.Request();this.requestInfo.extractRequestOptions(requestInfo,undefineRequestProps);if(this.requestInfo.method=="POST") -{if(!this.requestInfo.headers) -this.requestInfo.headers={};if(!this.requestInfo.headers['Content-Type']) -this.requestInfo.headers['Content-Type']="application/x-www-form-urlencoded; charset=UTF-8";}};Spry.Data.HTTPSourceDataSet.prototype.recalculateDataSetDependencies=function() -{this.hasDataRefStrings=false;var i=0;for(i=0;i0) -isDOMNodeArray=nodeArray[0].nodeType!=2;var nextID=0;var encodeText=true;var encodeCData=false;if(typeof entityEncodeStrings=="boolean") -encodeText=encodeCData=entityEncodeStrings;for(var i=0;i0) -{var processedSubPaths=[];var numSubPaths=subPaths.length;for(var i=0;iGenerated region markup for '"+this.name+"':

"+Spry.Utils.encodeEntities(str));Spry.Utils.setInnerHTML(this.regionNode,str,!Spry.Data.Region.evalScripts);if(this.hasBehaviorAttributes) -this.attachBehaviors();if(!suppressNotfications) -Spry.Data.Region.notifyObservers("onPostUpdate",this,notificationData);} -if(!suppressNotfications) -Spry.Data.Region.notifyObservers("onPostStateChange",this,stateObj);};Spry.Data.Region.prototype.getDataSets=function() -{return this.dataSets;};Spry.Data.Region.prototype.addDataSet=function(aDataSet) -{if(!aDataSet) -return;if(!this.dataSets) -this.dataSets=new Array;for(var i=0;i1) -{dsName=valArr[0];node.setAttribute(attr,valArr[1]);} -node.setAttribute(rowNumAttrName,"{"+(dsName?(dsName+"::"):"")+"ds_RowNumber}");};Spry.Data.Region.behaviorAttrs["spry:even"]={setup:function(node,value) -{Spry.Data.Region.setUpRowNumberForEvenOddAttr(node,"spry:even",value,"spryevenrownumber");},attach:function(rgn,node,value) -{if(value) -{rowNumAttr=node.attributes.getNamedItem("spryevenrownumber");if(rowNumAttr&&rowNumAttr.value) -{var rowNum=parseInt(rowNumAttr.value);if(rowNum%2) -Spry.Utils.addClassName(node,value);}} -node.removeAttribute("spry:even");node.removeAttribute("spryevenrownumber");}};Spry.Data.Region.behaviorAttrs["spry:odd"]={setup:function(node,value) -{Spry.Data.Region.setUpRowNumberForEvenOddAttr(node,"spry:odd",value,"spryoddrownumber");},attach:function(rgn,node,value) -{if(value) -{rowNumAttr=node.attributes.getNamedItem("spryoddrownumber");if(rowNumAttr&&rowNumAttr.value) -{var rowNum=parseInt(rowNumAttr.value);if(rowNum%2==0) -Spry.Utils.addClassName(node,value);}} -node.removeAttribute("spry:odd");node.removeAttribute("spryoddrownumber");}};Spry.Data.Region.setRowAttrClickHandler=function(node,dsName,rowAttr,funcName) -{if(dsName) -{var ds=Spry.Data.getDataSetByName(dsName);if(ds) -{rowIDAttr=node.attributes.getNamedItem(rowAttr);if(rowIDAttr) -{var rowAttrVal=rowIDAttr.value;if(rowAttrVal) -Spry.Utils.addEventListener(node,"click",function(event){ds[funcName](rowAttrVal);},false);}}}};Spry.Data.Region.behaviorAttrs["spry:setrow"]={setup:function(node,value) -{if(!value) -{Spry.Debug.reportError("The spry:setrow attribute requires a data set name as its value!");node.removeAttribute("spry:setrow");return;} -node.setAttribute("spryrowid","{"+value+"::ds_RowID}");},attach:function(rgn,node,value) -{Spry.Data.Region.setRowAttrClickHandler(node,value,"spryrowid","setCurrentRow");node.removeAttribute("spry:setrow");node.removeAttribute("spryrowid");}};Spry.Data.Region.behaviorAttrs["spry:setrownumber"]={setup:function(node,value) -{if(!value) -{Spry.Debug.reportError("The spry:setrownumber attribute requires a data set name as its value!");node.removeAttribute("spry:setrownumber");return;} -node.setAttribute("spryrownumber","{"+value+"::ds_RowID}");},attach:function(rgn,node,value) -{Spry.Data.Region.setRowAttrClickHandler(node,value,"spryrownumber","setCurrentRowNumber");node.removeAttribute("spry:setrownumber");node.removeAttribute("spryrownumber");}};Spry.Data.Region.behaviorAttrs["spry:sort"]={attach:function(rgn,node,value) -{if(!value) -return;var ds=rgn.getDataSets()[0];var sortOrder="toggle";var colArray=value.split(/\s/);if(colArray.length>1) -{var specifiedDS=Spry.Data.getDataSetByName(colArray[0]);if(specifiedDS) -{ds=specifiedDS;colArray.shift();} -if(colArray.length>1) -{var str=colArray[colArray.length-1];if(str=="ascending"||str=="descending"||str=="toggle") -{sortOrder=str;colArray.pop();}}} -if(ds&&colArray.length>0) -Spry.Utils.addEventListener(node,"click",function(event){ds.sort(colArray,sortOrder);},false);node.removeAttribute("spry:sort");}};Spry.Data.Region.prototype.attachBehaviors=function() -{var rgn=this;Spry.Utils.getNodesByFunc(this.regionNode,function(node) -{if(!node||node.nodeType!=1) -return false;try -{var bAttrs=Spry.Data.Region.behaviorAttrs;for(var bAttrName in bAttrs) -{var attr=node.attributes.getNamedItem(bAttrName);if(attr) -{var behavior=bAttrs[bAttrName];if(behavior&&behavior.attach) -behavior.attach(rgn,node,attr.value);}}}catch(e){} -return false;});};Spry.Data.Region.prototype.updateContent=function() -{var allDataSetsReady=true;var dsArray=this.getDataSets();if(!dsArray||dsArray.length<1) -{Spry.Debug.reportError("updateContent(): Region '"+this.name+"' has no data set!\n");return;} -for(var i=0;i]*>\s*-->/mg;var searchStartIndex=0;var processingContentTag=0;while(inStr.length) -{var results=regexp.exec(inStr);if(!results||!results[0]) -{outStr+=inStr.substr(searchStartIndex,inStr.length-searchStartIndex);break;} -if(!processingContentTag&&results.index!=searchStartIndex) -{outStr+=inStr.substr(searchStartIndex,results.index-searchStartIndex);} -if(results[0].search(/<\//)!=-1) -{--processingContentTag;if(processingContentTag) -Spry.Debug.reportError("Nested spry:content regions are not allowed!\n");} -else -{++processingContentTag;var dataRefStr=results[0].replace(/.*\bdataref="/,"");outStr+=dataRefStr.replace(/".*$/,"");} -searchStartIndex=regexp.lastIndex;} -return outStr;};Spry.Data.Region.prototype.tokenizeData=function(dataStr) -{if(!dataStr) -return null;var rootToken=new Spry.Data.Region.Token(Spry.Data.Region.Token.LIST_TOKEN,null,null,null);var tokenStack=new Array;var parseStr=Spry.Data.Region.processContentPI(dataStr);tokenStack.push(rootToken);var regexp=/((){0,1})|((\{|%7[bB])[^\}\s%]+(\}|%7[dD]))/mg;var searchStartIndex=0;while(parseStr.length) -{var results=regexp.exec(parseStr);var token=null;if(!results||!results[0]) -{var str=parseStr.substr(searchStartIndex,parseStr.length-searchStartIndex);token=new Spry.Data.Region.Token(Spry.Data.Region.Token.STRING_TOKEN,null,str,str);tokenStack[tokenStack.length-1].addChild(token);break;} -if(results.index!=searchStartIndex) -{var str=parseStr.substr(searchStartIndex,results.index-searchStartIndex);token=new Spry.Data.Region.Token(Spry.Data.Region.Token.STRING_TOKEN,null,str,str);tokenStack[tokenStack.length-1].addChild(token);} -if(results[0].search(/^({|%7[bB])/)!=-1) -{var valueName=results[0];var regionStr=results[0];valueName=valueName.replace(/^({|%7[bB])/,"");valueName=valueName.replace(/(}|%7[dD])$/,"");var dataSetName=null;var splitArray=valueName.split(/::/);if(splitArray.length>1) -{dataSetName=splitArray[0];valueName=splitArray[1];} -regionStr=regionStr.replace(/^%7[bB]/,"{");regionStr=regionStr.replace(/%7[dD]$/,"}");token=new Spry.Data.Region.Token(Spry.Data.Region.Token.VALUE_TOKEN,dataSetName,valueName,new String(regionStr));tokenStack[tokenStack.length-1].addChild(token);} -else if(results[0].charAt(0)=='<') -{var piName=results[0].replace(/^(){0,1}|\s.*$/,"");if(results[0].search(/<\//)!=-1) -{if(tokenStack[tokenStack.length-1].tokenType!=Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN) -{Spry.Debug.reportError("Invalid processing instruction close tag: "+piName+" -- "+results[0]+"\n");return null;} -tokenStack.pop();} -else -{var piDesc=Spry.Data.Region.PI.instructions[piName];if(piDesc) -{var dataSet=null;var selectedDataSetName="";if(results[0].search(/^.*\bselect=\"/)!=-1) -{selectedDataSetName=results[0].replace(/^.*\bselect=\"/,"");selectedDataSetName=selectedDataSetName.replace(/".*$/,"");if(selectedDataSetName) -{dataSet=Spry.Data.getDataSetByName(selectedDataSetName);if(!dataSet) -{Spry.Debug.reportError("Failed to retrieve data set ("+selectedDataSetName+") for "+piName+"\n");selectedDataSetName="";}}} -var jsExpr=null;if(results[0].search(/^.*\btest=\"/)!=-1) -{jsExpr=results[0].replace(/^.*\btest=\"/,"");jsExpr=jsExpr.replace(/".*$/,"");jsExpr=Spry.Utils.decodeEntities(jsExpr);} -var regionState=null;if(results[0].search(/^.*\bname=\"/)!=-1) -{regionState=results[0].replace(/^.*\bname=\"/,"");regionState=regionState.replace(/".*$/,"");regionState=Spry.Utils.decodeEntities(regionState);} -var piData=new Spry.Data.Region.Token.PIData(piName,selectedDataSetName,jsExpr,regionState);token=new Spry.Data.Region.Token(Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN,dataSet,piData,new String(results[0]));tokenStack[tokenStack.length-1].addChild(token);tokenStack.push(token);} -else -{Spry.Debug.reportError("Unsupported region processing instruction: "+results[0]+"\n");return null;}}} -else -{Spry.Debug.reportError("Invalid region token: "+results[0]+"\n");return null;} -searchStartIndex=regexp.lastIndex;} -return rootToken;};Spry.Data.Region.prototype.callScriptFunction=function(funcName,processContext) -{var result=undefined;funcName=funcName.replace(/^\s*\{?\s*function::\s*|\s*\}?\s*$/g,"");var func=Spry.Utils.getObjectByName(funcName);if(func) -result=func(this.name,function(){return processContext.getValueFromDataSet.apply(processContext,arguments);});return result;};Spry.Data.Region.prototype.evaluateExpression=function(exprStr,processContext) -{var result=undefined;try -{if(exprStr.search(/^\s*function::/)!=-1) -result=this.callScriptFunction(exprStr,processContext);else -result=Spry.Utils.eval(Spry.Data.Region.processDataRefString(processContext,exprStr,null,true));} -catch(e) -{Spry.Debug.trace("Caught exception in Spry.Data.Region.prototype.evaluateExpression() while evaluating: "+Spry.Utils.encodeEntities(exprStr)+"\n Exception:"+e+"\n");} -return result;};Spry.Data.Region.prototype.processTokenChildren=function(outputArr,token,processContext) -{var children=token.children;var len=children.length;for(var i=0;i0&&this.dataSets[0]) -{dataSet=this.dataSets[0];} -if(!dataSet) -{Spry.Debug.reportError("processTokens(): Value reference has no data set specified: "+token.regionStr+"\n");return"";} -val=processContext.getValueFromDataSet(dataSet,token.data);} -if(typeof val!="undefined") -outputArr.push(val+"");break;default:Spry.Debug.reportError("processTokens(): Invalid token type: "+token.regionStr+"\n");break;}};Spry.Data.Region.prototype.transform=function() -{if(this.data&&!this.tokens) -this.tokens=this.tokenizeData(this.data);if(!this.tokens) -return"";processContext=new Spry.Data.Region.ProcessingContext(this);if(!processContext) -return"";var outputArr=[""];this.processTokens(outputArr,this.tokens,processContext);return outputArr.join("");};Spry.Data.Region.PI={};Spry.Data.Region.PI.instructions={};Spry.Data.Region.PI.buildOpenTagForValueAttr=function(ele,piName,attrName) -{if(!ele||!piName) -return"";var jsExpr="";try -{var testAttr=ele.attributes.getNamedItem(piName);if(testAttr&&testAttr.value) -jsExpr=Spry.Utils.encodeEntities(testAttr.value);} -catch(e){jsExpr="";} -if(!jsExpr) -{Spry.Debug.reportError(piName+" attribute requires a JavaScript expression that returns true or false!\n");return"";} -return"<"+Spry.Data.Region.PI.instructions[piName].tagName+" "+attrName+"=\""+jsExpr+"\">";};Spry.Data.Region.PI.buildOpenTagForTest=function(ele,piName) -{return Spry.Data.Region.PI.buildOpenTagForValueAttr(ele,piName,"test");};Spry.Data.Region.PI.buildOpenTagForState=function(ele,piName) -{return Spry.Data.Region.PI.buildOpenTagForValueAttr(ele,piName,"name");};Spry.Data.Region.PI.buildOpenTagForRepeat=function(ele,piName) -{if(!ele||!piName) -return"";var selectAttrStr="";try -{var selectAttr=ele.attributes.getNamedItem(piName);if(selectAttr&&selectAttr.value) -{selectAttrStr=selectAttr.value;selectAttrStr=selectAttrStr.replace(/\s/g,"");}} -catch(e){selectAttrStr="";} -if(!selectAttrStr) -{Spry.Debug.reportError(piName+" attribute requires a data set name!\n");return"";} -var testAttrStr="";try -{var testAttr=ele.attributes.getNamedItem("spry:test");if(testAttr) -{if(testAttr.value) -testAttrStr=" test=\""+Spry.Utils.encodeEntities(testAttr.value)+"\"";ele.attributes.removeNamedItem(testAttr.nodeName);}} -catch(e){testAttrStr="";} -return"<"+Spry.Data.Region.PI.instructions[piName].tagName+" select=\""+selectAttrStr+"\""+testAttrStr+">";};Spry.Data.Region.PI.buildOpenTagForContent=function(ele,piName) -{if(!ele||!piName) -return"";var dataRefStr="";try -{var contentAttr=ele.attributes.getNamedItem(piName);if(contentAttr&&contentAttr.value) -dataRefStr=Spry.Utils.encodeEntities(contentAttr.value);} -catch(e){dataRefStr="";} -if(!dataRefStr) -{Spry.Debug.reportError(piName+" attribute requires a data reference!\n");return"";} -return"<"+Spry.Data.Region.PI.instructions[piName].tagName+" dataref=\""+dataRefStr+"\">";};Spry.Data.Region.PI.buildOpenTag=function(ele,piName) -{return"<"+Spry.Data.Region.PI.instructions[piName].tagName+">";};Spry.Data.Region.PI.buildCloseTag=function(ele,piName) -{return"";};Spry.Data.Region.PI.instructions["spry:state"]={tagName:"spry:state",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForState,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:if"]={tagName:"spry:if",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForTest,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:repeat"]={tagName:"spry:repeat",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForRepeat,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:repeatchildren"]={tagName:"spry:repeat",childrenOnly:true,getOpenTag:Spry.Data.Region.PI.buildOpenTagForRepeat,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:choose"]={tagName:"spry:choose",childrenOnly:true,getOpenTag:Spry.Data.Region.PI.buildOpenTag,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:when"]={tagName:"spry:when",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForTest,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:default"]={tagName:"spry:default",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTag,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:content"]={tagName:"spry:content",childrenOnly:true,getOpenTag:Spry.Data.Region.PI.buildOpenTagForContent,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.orderedInstructions=["spry:state","spry:if","spry:repeat","spry:repeatchildren","spry:choose","spry:when","spry:default","spry:content"];Spry.Data.Region.getTokensFromStr=function(str) -{if(!str) -return null;return str.match(/{[^}]+}/g);};Spry.Data.Region.processDataRefString=function(processingContext,regionStr,dataSetsToUse,isJSExpr) -{if(!regionStr) -return"";if(!processingContext&&!dataSetsToUse) -return regionStr;var resultStr="";var re=new RegExp("\\{([^\\}:]+::)?[^\\}]+\\}","g");var startSearchIndex=0;while(startSearchIndexdata.length) -{Spry.Debug.reportError("Invalid index used in Spry.Data.Region.DSContext.getCurrentRow()!\n");return null;} -return data[curRowIndex];};this.getRowIndex=function() -{var curRowIndex=getInternalRowIndex();if(curRowIndex>=0) -return curRowIndex;return m_dataSet.getRowNumber(m_dataSet.getCurrentRow());};this.setRowIndex=function(rowIndex) -{this.getCurrentState().rowIndex=rowIndex;var data=this.getData();var numChildren=m_children.length;for(var i=0;i0) -return this.dataSetContexts[0];return null;} -if(typeof dataSet=='string') -{dataSet=Spry.Data.getDataSetByName(dataSet);if(!dataSet) -return null;} -for(var i=0;i1) -{dsName=arguments[0];columnName=arguments[1];} -else -{var dataRef=arguments[0].replace(/\s*{\s*|\s*}\s*/g,"");if(dataRef.search("::")!=-1) -{dsName=dataRef.replace(/::.*/,"");columnName=dataRef.replace(/.*::/,"");} -else -columnName=dataRef;} -var result="";var dsContext=this.getDataSetContext(dsName);if(dsContext) -result=dsContext.getValue(columnName,dsContext.getCurrentRow());else -Spry.Debug.reportError("getValueFromDataSet: Failed to get "+dsName+" context for the "+this.region.regionNode.id+" region.\n");return result;};Spry.Data.Region.ProcessingContext.prototype.$v=Spry.Data.Region.ProcessingContext.prototype.getValueFromDataSet;Spry.Data.Region.ProcessingContext.prototype.getCurrentRowForDataSet=function(dataSet) -{var dsc=this.getDataSetContext(dataSet);if(dsc) -return dsc.getCurrentRow();return null;};Spry.Data.Region.Token=function(tokenType,dataSet,data,regionStr) -{var self=this;this.tokenType=tokenType;this.dataSet=dataSet;this.data=data;this.regionStr=regionStr;this.parent=null;this.children=null;};Spry.Data.Region.Token.prototype.addChild=function(child) -{if(!child) -return;if(!this.children) -this.children=new Array;this.children.push(child);child.parent=this;};Spry.Data.Region.Token.LIST_TOKEN=0;Spry.Data.Region.Token.STRING_TOKEN=1;Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN=2;Spry.Data.Region.Token.VALUE_TOKEN=3;Spry.Data.Region.Token.PIData=function(piName,data,jsExpr,regionState) -{var self=this;this.name=piName;this.data=data;this.jsExpr=jsExpr;this.regionState=regionState;};Spry.Utils.addLoadListener(function(){setTimeout(function(){if(Spry.Data.initRegionsOnLoad)Spry.Data.initRegions();},0);}); \ No newline at end of file