OpenLayers OpenLayers

Changeset 7092

Show
Ignore:
Timestamp:
05/07/08 19:50:26 (3 months ago)
Author:
tschaub
Message:

doc/examples.html update

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/doc/Jugl.js

    r6131 r7092  
    11/** 
    2  * Jugl.js -- JavaScript Template Attribute Language 
     2 * Jugl.js -- JavaScript Template Library 
    33 * This code is not yet licensed for release or distribution. 
    44 * 
     
    66 */ 
    77 
    8 /** 
    9  * Contains portions of OpenLayers.js -- OpenLayers Map Viewer Library 
    10  * 
    11  * Copyright 2005-2006 MetaCarta, Inc., released under a modified BSD license. 
    12  * Please see http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
    13  * for the full text of the license. 
    14  */ 
    15  
    16 /** 
    17  * Contains portions of Prototype.js: 
    18  * 
    19  * Prototype JavaScript framework, version 1.4.0 
    20  *  (c) 2005 Sam Stephenson <sam@conio.net> 
    21  * 
    22  *  Prototype is freely distributable under the terms of an MIT-style license. 
    23  *  For details, see the Prototype web site: http://prototype.conio.net/ 
    24  */ 
    25  
    26 (function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl={singleFile:true};window[uri]=Jugl;})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var singleFile=(typeof window[uri]=="object"&&window[uri].singleFile);var Jugl={prefix:"jugl",namespaceURI:"http://namespace.jugl.org/",scriptName:(!singleFile)?"lib/Jugl.js":"Jugl.js",getScriptLocation:function(){var scriptLocation="";var scriptName=Jugl.scriptName;var scripts=document.getElementsByTagName('script');for(var i=0;i<scripts.length;i++){var src=scripts[i].getAttribute('src');if(src){var index=src.lastIndexOf(scriptName);if((index>-1)&&(index+scriptName.length==src.length)){scriptLocation=src.slice(0,-scriptName.length);break;}}} 
    27 return scriptLocation;}};if(!singleFile){var jsfiles=new Array("Jugl/Util.js","Jugl/Class.js","Jugl/Async.js","Jugl/Node.js","Jugl/Attribute.js","Jugl/Console.js","Jugl/Template.js");var allScriptTags="";var host=Jugl.getScriptLocation()+"lib/";for(var i=0;i<jsfiles.length;i++){if(/MSIE/.test(navigator.userAgent)||/Safari/.test(navigator.userAgent)){var currentScriptTag="<script src='"+host+jsfiles[i]+"'></script>";allScriptTags+=currentScriptTag;}else{var s=document.createElement("script");s.src=host+jsfiles[i];var h=document.getElementsByTagName("head").length?document.getElementsByTagName("head")[0]:document.body;h.appendChild(s);}} 
    28 if(allScriptTags){document.write(allScriptTags);}} 
    29 window[uri]=Jugl;})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Class=function(){var Class=function(){this.initialize.apply(this,arguments);} 
    30 var extended={};var parent;for(var i=0;i<arguments.length;++i){if(typeof arguments[i]=="function"){parent=arguments[i].prototype;}else{parent=arguments[i];} 
     8(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl={prefix:"jugl",namespaceURI:"http://namespace.jugl.org/"};window[uri]=Jugl;})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Class=function(){var Class=function(){if(this===Jugl){var msg="Create an instance of a Jugl "+"class with the new keyword";throw Error(msg);} 
     9this.initialize.apply(this,arguments);} 
     10var extended={toString:function(){return"["+this.CLASS_NAME+"]";}};var parent;for(var i=0;i<arguments.length;++i){if(typeof arguments[i]=="function"){parent=arguments[i].prototype;}else{parent=arguments[i];} 
    3111Jugl.Util.extend(extended,parent);} 
    3212Class.prototype=extended;return Class;};})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Util=new Object();Jugl.Util.extend=function(destination,source){for(property in source){destination[property]=source[property];} 
     
    3414return-1;};Jugl.Util.bind=function(method,object){var args=[];for(var i=2;i<arguments.length;++i){args.push(arguments[i]);} 
    3515return function(){for(var i=0;i<arguments.length;++i){args.push(arguments[i]);} 
    36 return method.apply(object,args);}};})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Console={log:function(){},debug:function(){},info:function(){},warn:function(){},error:function(){},assert:function(){},dir:function(){},dirxml:function(){},trace:function(){},group:function(){},groupEnd:function(){},time:function(){},timeEnd:function(){},profile:function(){},profileEnd:function(){},count:function(){}};(function(){if(window.console){var scripts=document.getElementsByTagName("script");for(var i=0;i<scripts.length;++i){if(scripts[i].src.indexOf("firebug.js")!=-1){Jugl.Util.extend(Jugl.Console,console);break;}}}})();})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Attribute=Jugl.Class({node:null,element:null,type:null,nodeValue:null,template:null,initialize:function(node,element,type){this.node=node;this.element=element;this.type=type;this.nodeValue=element.nodeValue;this.nodeName=element.nodeName;this.template=node.template;},splitAttributeValue:function(value){value=(value!=null)?value:this.nodeValue;var matches=this.template.regExes.trimSpace.exec(value);var items;if(matches.length==3){items=[matches[1],matches[2]];} 
    37 return items;},getAttributeValues:function(){var trimmed=this.nodeValue.replace(/[\t\n]/g,"").replace(/;\s*$/,"");var tabbed=trimmed.replace(/;;/g,"\t");var newlined=tabbed.split(";").join("\n");return newlined.replace(/\t/g,";").split(/\n/g);},removeSelf:function(){this.node.removeAttributeNode(this);},process:function(){return this.processAttribute[this.type].apply(this,[]);},evalInScope:function(str){var expression="with(this.node.scope){"+str+"}";return eval(expression);},processAttribute:{"define":function(){var values=this.getAttributeValues();var pair;for(var i=0;i<values.length;++i){pair=this.splitAttributeValue(values[i]);this.node.scope[pair[0]]=this.evalInScope(pair[1]);} 
    38 this.removeSelf();return true;},"condition":function(){var proceed;try{proceed=!!(this.evalInScope(this.nodeValue));}catch(err){var message=err.name+": "+err.message+"\n";message+="attribute: "+this.nodeName;Jugl.Console.error(message);Jugl.Console.dirxml(this.node.element);Jugl.Console.log(this.node.scope);} 
    39 this.removeSelf();if(!proceed){this.node.removeSelf();} 
     16return method.apply(object,args);}};})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Console={log:function(){},debug:function(){},info:function(){},warn:function(){},error:function(){},assert:function(){},dir:function(){},dirxml:function(){},trace:function(){},group:function(){},groupEnd:function(){},time:function(){},timeEnd:function(){},profile:function(){},profileEnd:function(){},count:function(){}};(function(){if(window.console){var scripts=document.getElementsByTagName("script");for(var i=0;i<scripts.length;++i){if(scripts[i].src.indexOf("firebug.js")!=-1){Jugl.Util.extend(Jugl.Console,console);break;}}}})();})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Attribute=Jugl.Class({element:null,node:null,type:null,nodeValue:null,template:null,initialize:function(element,node,type){this.element=element;this.node=node;this.type=type;this.nodeValue=node.nodeValue;this.nodeName=node.nodeName;this.template=element.template;},splitAttributeValue:function(value){value=(value!=null)?value:this.nodeValue;var matches=this.template.regExes.trimSpace.exec(value);var items;if(matches&&matches.length==3){items=[matches[1],matches[2]];} 
     17return items;},splitExpressionPrefix:function(){var items=this.splitAttributeValue();if(!items||(items[0]!='structure'&&items[0]!='text')){items=[null,this.nodeValue];} 
     18return items;},getAttributeValues:function(){var trimmed=this.nodeValue.replace(/[\t\n]/g,"").replace(/;\s*$/,"");var tabbed=trimmed.replace(/;;/g,"\t");var newlined=tabbed.split(";").join("\n");return newlined.replace(/\t/g,";").split(/\n/g);},removeSelf:function(){this.element.removeAttributeNode(this);},process:function(){return this.processAttribute[this.type].apply(this,[]);},evalInScope:function(str){var expression="with(this.element.scope){"+str+"}";return eval(expression);},processAttribute:{"define":function(){var values=this.getAttributeValues();var pair;for(var i=0;i<values.length;++i){pair=this.splitAttributeValue(values[i]);this.element.scope[pair[0]]=this.evalInScope(pair[1]);} 
     19this.removeSelf();return true;},"condition":function(){var proceed;try{proceed=!!(this.evalInScope(this.nodeValue));}catch(err){var message=err.name+": "+err.message+"\n"+"attribute: "+this.nodeName;Jugl.Console.error(message);throw err;} 
     20this.removeSelf();if(!proceed){this.element.removeSelf();} 
    4021return proceed;},"repeat":function(){var pair=this.splitAttributeValue();var key=pair[0];var list=this.evalInScope(pair[1]);this.removeSelf();if(!(list instanceof Array)){var items=new Array();for(var p in list){items.push(p);} 
    4122list=items;} 
    42 var node;var previousSibling=this.node;var length=list.length;for(var i=0;i<length;++i){node=this.node.clone();node.scope[key]=list[i];node.scope.repeat[key]={index:i,number:i+1,even:!(i%2),odd:!!(i%2),start:(i==0),end:(i==length-1),length:length};previousSibling.insertAfter(node);node.process();previousSibling=node;} 
    43 this.node.removeSelf();return false;},"content":function(){var str;try{str=this.evalInScope(this.nodeValue);}catch(err){Jugl.Console.error("Failed to eval in node scope: "+ 
     23var element;var previousSibling=this.element;var length=list.length;for(var i=0;i<length;++i){element=this.element.clone();element.scope[key]=list[i];element.scope.repeat[key]={index:i,number:i+1,even:!(i%2),odd:!!(i%2),start:(i==0),end:(i==length-1),length:length};previousSibling.insertAfter(element);element.process();previousSibling=element;} 
     24this.element.removeSelf();return false;},"content":function(){var pair=this.splitExpressionPrefix();var str;try{str=this.evalInScope(pair[1]);}catch(err){Jugl.Console.error("Failed to eval in element scope: "+ 
     25pair[1]);throw err;} 
     26this.removeSelf();if(pair[0]=='structure'){try{this.element.node.innerHTML=str;}catch(err){var wrapper=document.createElement('div');var msg;try{wrapper.innerHTML=str;}catch(invalidHTML){msg="Can't transform string into valid HTML : "+ 
     27str;Jugl.Console.error(msg);throw invalidHTML;} 
     28if(this.element.node.xml&&this.template.xmldom){while(this.element.node.firstChild){this.element.node.removeChild(this.element.node.firstChild);} 
     29this.template.xmldom.loadXML(wrapper.outerHTML);var children=this.template.xmldom.firstChild.childNodes;try{for(var i=0;i<children.length;++i){this.element.node.appendChild(children[i]);}}catch(invalidXML){msg="Can't transform string into valid XHTML : "+ 
     30str;Jugl.Console.error(msg);throw invalidXML;}}else{try{this.element.node.innerHTML=wrapper.innerHTML;}catch(invalidXML){msg="Can't transform string into valid XHTML : "+ 
     31str;Jugl.Console.error(msg);throw invalidXML;}}}}else{var text;if(this.element.node.xml&&this.template.xmldom){text=this.template.xmldom.createTextNode(str);}else{text=document.createTextNode(str);} 
     32var child=new Jugl.Element(this.template,text);this.element.removeChildNodes();this.element.appendChild(child);} 
     33return true;},"replace":function(){var pair=this.splitExpressionPrefix();var str;try{str=this.evalInScope(pair[1]);}catch(err){Jugl.Console.error("Failed to eval in element scope: "+ 
     34pair[1]);throw err;} 
     35this.removeSelf();if(pair[0]=='structure'){var wrapper=document.createElement('div');try{wrapper.innerHTML=str;}catch(err){msg="Can't transform string into valid HTML : "+ 
     36str;Jugl.Console.error(msg);throw err;} 
     37if(this.element.node.xml&&this.template.xmldom){try{this.template.xmldom.loadXML(wrapper.outerHTML);}catch(err){msg="Can't transform string into valid XML : "+ 
     38str;Jugl.Console.error(msg);throw err;} 
     39wrapper=this.template.xmldom.firstChild;} 
     40while(wrapper.firstChild){var child=wrapper.removeChild(wrapper.firstChild);if(this.element.node.ownerDocument&&this.element.node.ownerDocument.importNode){if(child.ownerDocument!=this.element.node.ownerDocument){child=this.element.node.ownerDocument.importNode(child,true);}} 
     41this.element.node.parentNode.insertBefore(child,this.element.node);}}else{var text;if(this.element.node.xml&&this.template.xmldom){text=this.template.xmldom.createTextNode(str);}else{text=document.createTextNode(str);} 
     42var replacement=new Jugl.Element(this.template,text);this.element.insertBefore(replacement);} 
     43this.element.removeSelf();return true;},"attributes":function(){var values=this.getAttributeValues();var pair,name,value;for(var i=0;i<values.length;++i){pair=this.splitAttributeValue(values[i]);name=pair[0];value=this.evalInScope(pair[1]);if(value!==false){this.element.setAttribute(name,value);}} 
     44this.removeSelf();return true;},"omit-tag":function(){var omit;try{omit=((this.nodeValue=="")||!!(this.evalInScope(this.nodeValue)));}catch(err){Jugl.Console.error("Failed to eval in element scope: "+ 
    4445this.nodeValue);throw err;} 
    45 this.removeSelf();var child=new Jugl.Node(this.template,document.createTextNode(str));this.node.removeChildNodes();this.node.appendChild(child);return true;},"replace":function(){var str;try{str=this.evalInScope(this.nodeValue);}catch(err){Jugl.Console.error("Failed to eval in node scope: "+ 
     46this.removeSelf();if(omit){var children=this.element.getChildNodes();var child;for(var i=0;i<children.length;++i){this.element.insertBefore(children[i]);} 
     47this.element.removeSelf();}},"reflow":function(){var reflow;try{reflow=((this.nodeValue=="")||!!(this.evalInScope(this.nodeValue)));}catch(err){Jugl.Console.error("Failed to eval in element scope: "+ 
    4648this.nodeValue);throw err;} 
    47 this.removeSelf();var replacement=new Jugl.Node(this.template,document.createTextNode(str));this.node.insertBefore(replacement);this.node.removeSelf();return true;},"attributes":function(){var values=this.getAttributeValues();var pair,name,value;for(var i=0;i<values.length;++i){pair=this.splitAttributeValue(values[i]);name=pair[0];value=this.evalInScope(pair[1]);if(value!==false){this.node.setAttribute(name,value);}} 
    48 this.removeSelf();return true;},"omit-tag":function(){var omit;try{omit=((this.nodeValue=="")||!!(this.evalInScope(this.nodeValue)));}catch(err){Jugl.Console.error("Failed to eval in node scope: "+ 
    49 this.nodeValue);throw err;} 
    50 this.removeSelf();if(omit){var children=this.node.getChildNodes();var child;for(var i=0;i<children.length;++i){this.node.insertBefore(children[i]);} 
    51 this.node.removeSelf();}}},CLASS_NAME:"Jugl.Attribute"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Template=Jugl.Class({element:null,usingNS:false,xhtmlns:"http://www.w3.org/1999/xhtml",xmldom:null,regExes:null,loaded:false,loading:false,initialize:function(element,options){if(typeof(element)=="string"){element=document.getElementById(element);} 
    52 if(element){this.element=element;this.loaded=true;} 
    53 this.regExes={trimSpace:(/^\s*(\w+)\s+(.*?)\s*$/)};if(window.ActiveXObject){this.xmldom=new ActiveXObject("Microsoft.XMLDOM");}},process:function(context,clone,toString){if(this.element.getAttributeNodeNS){if(this.element.getAttributeNodeNS(Jugl.xhtmlns,Jugl.prefix)){this.usingNS=true;}} 
    54 var node=new Jugl.Node(this,this.element);if(clone){node=node.clone();} 
    55 if(context){node.scope=context;} 
    56 try{node.process();}catch(err){Jugl.Console.error("Failed to process "+ 
    57 this.element+" node");} 
    58 var data;if(toString){if(node.element.innerHTML){data=node.element.innerHTML;}else{if(this.xmldom){data=node.element.xml;}else{var serializer=new XMLSerializer();data=serializer.serializeToString(node.element);}}}else{data=node.element;} 
    59 return data;},load:function(url){this.loading=true;var setElement=function(request){var doc=request.responseXML;this.element=doc.documentElement;this.loading=false;this.loaded=true;this.onLoad();} 
    60 Jugl.Async.loadUrl(url,setElement,this);},onLoad:function(){},CLASS_NAME:"Jugl.Template"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Node=Jugl.Class({template:null,element:null,scope:null,initialize:function(template,element){this.template=template;this.element=element;this.scope=new Object();this.scope.repeat=new Object();},clone:function(){var element=this.element.cloneNode(true);var node=new Jugl.Node(this.template,element);Jugl.Util.extend(node.scope,this.scope);return node;},getAttribute:function(localName){var element;if(this.element.nodeType==1){if(this.template.usingNS){element=this.element.getAttributeNodeNS(Jugl.namespaceURI,localName);}else{element=this.element.getAttributeNode(Jugl.prefix+":"+ 
     49this.removeSelf();if(reflow){if(this.element.node.outerHTML){this.element.node.outerHTML=this.element.node.outerHTML;}else{this.element.node.innerHTML=this.element.node.innerHTML;}}}},CLASS_NAME:"Jugl.Attribute"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Element=Jugl.Class({template:null,node:null,scope:null,initialize:function(template,node){this.template=template;this.node=node;this.scope=new Object();this.scope.repeat=new Object();},clone:function(){var node=this.node.cloneNode(true);node.removeAttribute("id");var element=new Jugl.Element(this.template,node);Jugl.Util.extend(element.scope,this.scope);return element;},getAttribute:function(localName){var node;if(this.node.nodeType==1){if(this.template.usingNS){node=this.node.getAttributeNodeNS(Jugl.namespaceURI,localName);}else{node=this.node.getAttributeNode(Jugl.prefix+":"+ 
    6150localName);} 
    62 if(element&&!element.specified){element=false;}} 
    63 var attribute;if(element){attribute=new Jugl.Attribute(this,element,localName);}else{attribute=element;} 
    64 return attribute;},setAttribute:function(name,value){this.element.setAttribute(name,value);},removeAttributeNode:function(attribute){this.element.removeAttributeNode(attribute.element);},getChildNodes:function(){var children=[];var node,scope;for(var i=0;i<this.element.childNodes.length;++i){node=new Jugl.Node(this.template,this.element.childNodes[i]);node.scope=Jugl.Util.extend({},this.scope);children.push(node);} 
    65 return children;},removeChildNodes:function(){while(this.element.hasChildNodes()){this.element.removeChild(this.element.firstChild);}},removeChild:function(node){this.element.removeChild(node.element);return node;},removeSelf:function(){this.element.parentNode.removeChild(this.element);},appendChild:function(node){this.element.appendChild(node.element);},insertAfter:function(node){var parent=this.element.parentNode;var sibling=this.element.nextSibling;if(sibling){parent.insertBefore(node.element,sibling);}else{parent.appendChild(node.element);}},insertBefore:function(node){var parent=this.element.parentNode;parent.insertBefore(node.element,this.element);},process:function(){var attribute;var keepProcessing=true;var series=["define","condition","repeat"];for(var i=0;i<series.length;++i){attribute=this.getAttribute(series[i]);if(attribute){try{keepProcessing=attribute.process();}catch(err){Jugl.Console.error("Failed to process "+ 
     51if(node&&!node.specified){node=false;}} 
     52var attribute;if(node){attribute=new Jugl.Attribute(this,node,localName);}else{attribute=node;} 
     53return attribute;},setAttribute:function(name,value){this.node.setAttribute(name,value);},removeAttributeNode:function(attribute){this.node.removeAttributeNode(attribute.node);},getChildNodes:function(){var numNodes=this.node.childNodes.length;var children=new Array(numNodes);var node,scope;for(var i=0;i<numNodes;++i){node=new Jugl.Element(this.template,this.node.childNodes[i]);node.scope=Jugl.Util.extend({},this.scope);children[i]=node;} 
     54return children;},removeChildNodes:function(){while(this.node.hasChildNodes()){this.node.removeChild(this.node.firstChild);}},removeChild:function(element){this.node.removeChild(element.node);return node;},removeSelf:function(){this.node.parentNode.removeChild(this.node);},importNode:function(element){if(this.node.ownerDocument&&this.node.ownerDocument.importNode){if(element.node.ownerDocument!=this.node.ownerDocument){element.node=this.node.ownerDocument.importNode(element.node,true);}}},appendChild:function(element){this.importNode(element);this.node.appendChild(element.node);},insertAfter:function(element){this.importNode(element);var parent=this.node.parentNode;var sibling=this.node.nextSibling;if(sibling){parent.insertBefore(element.node,sibling);}else{parent.appendChild(element.node);}},insertBefore:function(element){this.importNode(element);var parent=this.node.parentNode;parent.insertBefore(element.node,this.node);},process:function(){var attribute;var keepProcessing=true;var series=["define","condition","repeat"];for(var i=0;i<series.length;++i){attribute=this.getAttribute(series[i]);if(attribute){try{keepProcessing=attribute.process();}catch(err){Jugl.Console.error("Failed to process "+ 
    6655series[i]+" attribute");throw err;} 
    6756if(!keepProcessing){return;}}} 
     
    6958var attributes=this.getAttribute("attributes");if(attributes){try{attributes.process();}catch(err){Jugl.Console.error("Failed to process attributes attribute");throw err;}} 
    7059if(!content&&!replace){this.processChildNodes();} 
    71 var omit=this.getAttribute("omit-tag");if(omit){try{omit.process();}catch(err){Jugl.Console.error("Failed to process omit-tag attribute");throw err;}}},processChildNodes:function(){var element,child;var children=this.getChildNodes();for(var i=0;i<children.length;++i){try{children[i].process();}catch(err){Jugl.Console.error("Failed to process "+ 
    72 children[i]+" node");throw err;}}},CLASS_NAME:"Jugl.Node"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Async={loadTemplate:function(url,onComplete,caller){var createTemplate=function(request){var doc=request.responseXML;var template=new Jugl.Template(doc.documentElement);var complete=Jugl.Util.bind(onComplete,caller);complete(template);} 
    73 Jugl.Async.loadUrl(url,createTemplate);},loadUrl:function(url,onComplete,caller){var complete=(caller)?Jugl.Util.bind(onComplete,caller):onComplete;var request=Jugl.Async.createXMLHttpRequest();request.open("GET",url);request.onreadystatechange=function(){if(request.readyState==4){complete(request);}} 
     60var omit=this.getAttribute("omit-tag");if(omit){try{omit.process();}catch(err){Jugl.Console.error("Failed to process omit-tag attribute");throw err;}} 
     61var reflow=this.getAttribute("reflow");if(reflow){try{reflow.process();}catch(err){Jugl.Console.error("Failed to process reflow attribute");throw err;}}},processChildNodes:function(){var children=this.getChildNodes();for(var i=0;i<children.length;++i){try{children[i].process();}catch(err){Jugl.Console.error("Failed to process child node: "+i);throw err;}}},CLASS_NAME:"Jugl.Element"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Template=Jugl.Class({node:null,usingNS:false,xhtmlns:"http://www.w3.org/1999/xhtml",xmldom:null,regExes:null,loaded:false,loading:false,initialize:function(node,options){if(typeof(node)=="string"){var obj=document.getElementById(node);if(!obj){throw Error("Element id not found: "+node);} 
     62node=obj;} 
     63if(node){this.node=node;this.loaded=true;} 
     64this.regExes={trimSpace:(/^\s*(\w+)\s+(.*?)\s*$/)};if(window.ActiveXObject){this.xmldom=new ActiveXObject("Microsoft.XMLDOM");}},process:function(context,clone,toString){if(this.node.getAttributeNodeNS){if(this.node.getAttributeNodeNS(Jugl.xhtmlns,Jugl.prefix)){this.usingNS=true;}} 
     65var element=new Jugl.Element(this,this.node);if(clone){element=element.clone();} 
     66if(context){element.scope=context;} 
     67try{element.process();}catch(err){Jugl.Console.error("Failed to process "+ 
     68this.node.nodeName+" node");throw err;} 
     69var data;if(toString){if(element.node.innerHTML){data=element.node.innerHTML;}else{if(this.xmldom){data=element.node.xml;}else{var serializer=new XMLSerializer();data=serializer.serializeToString(element.node);}}}else{data=element.node;} 
     70return data;},load:function(url){this.loading=true;var setNode=function(template){this.node=template.node;this.loading=false;this.loaded=true;this.onLoad();} 
     71Jugl.Request.loadTemplate(url,setNode,this);},onLoad:function(){},appendTo:function(node){if(typeof(node)=="string"){var obj=document.getElementById(node);if(!obj){throw Error("Element id not found: "+node);} 
     72node=obj;} 
     73if(node){if(this.node.namespaceURI&&this.node.xml){var wrapper=document.createElement('div');wrapper.innerHTML=this.node.xml;var children=wrapper.childNodes;for(var i=0;i<children.length;++i){node.appendChild(children[i]);}}else{if(node.ownerDocument&&node.ownerDocument.importNode){this.node=node.ownerDocument.importNode(this.node,true);} 
     74node.appendChild(this.node);}}},CLASS_NAME:"Jugl.Template"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Request={loadTemplate:function(url,onComplete,caller){var createTemplate=function(request){var doc,template;try{doc=request.responseXML;template=new Jugl.Template(doc.documentElement);}catch(invalidXML){try{doc=document.createElement("div");doc.innerHTML=request.responseText;template=new Jugl.Template(doc.firstChild);}catch(invalidHTML){var msg="Can't make HTML out of response: "+ 
     75request.responseText;Jugl.Console.error(msg);throw invalidHTML;}} 
     76var complete=Jugl.Util.bind(onComplete,caller);complete(template);} 
     77Jugl.Request.loadUrl(url,createTemplate);},loadUrl:function(url,onComplete,caller){var complete=(caller)?Jugl.Util.bind(onComplete,caller):onComplete;var request=Jugl.Request.createXMLHttpRequest();request.open("GET",url);request.onreadystatechange=function(){if(request.readyState==4){complete(request);}} 
    7478request.send(null);},createXMLHttpRequest:function(){if(typeof XMLHttpRequest!="undefined"){return new XMLHttpRequest();}else if(typeof ActiveXObject!="undefined"){return new ActiveXObject("Microsoft.XMLHTTP");}else{throw new Error("XMLHttpRequest not supported");}}};})(); 
  • trunk/openlayers/doc/examples.html

    r6131 r7092  
    44        <title>OL Docs</title> 
    55        <style type="text/css"> 
    6             html, body {margin: 0;padding: 0.5em 1em;font: 0.9em Verdana, Arial, sans serif;} 
    7             .exampleContainer{width:90%; padding:5px; border-bottom:1px solid grey; } 
    8             .exampleNumber{display:inline; font-weight:bold; color:#333; } 
    9             .exampleTitle{display:inline; font-weight:bold; color:#333; } 
    10             .exampleName{display:inline; color:#333; } 
    11             .exampleDescription{color:#222; padding:3px; font-size:1.2em; } 
    12             .exampleClasses{font-size:.7em; color:grey;display:none;} 
     6            html, body { 
     7                height: 100%; 
     8                overflow: hidden; 
     9                margin: 0; 
     10                padding: 0; 
     11                font: 0.9em Verdana, Arial, sans serif; 
     12            } 
     13            .ex_container{ 
     14                border-bottom: 1px solid grey; 
     15            } 
     16            .ex_container a { 
     17                padding: 5px 1em; 
     18                display: block; 
     19            } 
     20            .ex_container a:hover { 
     21                background-color: #eeeeee; 
     22            } 
     23            .ex_title{ 
     24                display: inline; 
     25                font-weight: bold; 
     26                color: #333; 
     27            } 
     28            .ex_description{ 
     29                color: #222; 
     30                padding: 3px; 
     31            } 
     32            .ex_classes{ 
     33                font-size: .7em; 
     34                color: grey; 
     35                display: none; 
     36            } 
     37            #toc { 
     38                width: 30%; 
     39                height: 100%; 
     40                overflow: auto; 
     41            } 
     42            #instructions { 
     43                padding: 0.5em 1em 0; 
     44            } 
     45            #exwin { 
     46                position: absolute; 
     47                top: 0; 
     48                left: 30%; 
     49                width: 70%; 
     50                height: 100%; 
     51                border: 1px solid grey; 
     52                margin: 0; 
     53            } 
    1354        </style> 
    1455        <script type="text/javascript" src="./Jugl.js"></script> 
     
    2061            // this part does the actual template processing 
    2162            window.onload = function() { 
    22                 var template = new Jugl.Template("basic"); 
    23                 template.process(); 
     63                var template = new Jugl.Template("template"); 
     64                var node = template.process(null, true); 
     65                document.getElementById("examples").appendChild(node); 
     66                document.getElementById("exwin").src = "../examples/example.html"; 
    2467            } 
    2568        </script> 
    2669    </head> 
    2770    <body> 
    28         <div id="basic" style="margin: 0 auto;"> 
    29             <div class="exampleContainer" jugl:repeat="example examples"> 
    30                 <div class="exampleNumber" jugl:content="repeat.example.number"> 
    31                     Example # goes here 
    32                 </div> 
    33                 <div class="exampleTitle" jugl:content="example.title"> 
    34                     Title goes here 
    35                 </div> 
    36                 <div class="exampleName"> 
    37                     <a jugl:content="example.example" 
    38                      jugl:attributes="href example.link"> 
    39                     Example Filename and Link 
     71        <div id="toc"> 
     72            <p id="instructions">Click an example link below to view on the right.</p> 
     73            <div id="examples"></div> 
     74        </div> 
     75        <iframe id="exwin" name="exwin"></iframe> 
     76         
     77        <div style="display: none;"> 
     78            <div id="template"> 
     79                <div class="ex_container" jugl:repeat="example examples"> 
     80                    <a jugl:attributes="href example.link" target="exwin"> 
     81                        <h3 class="ex_title"> 
     82                            <span jugl:replace="example.title">title</span><br /> 
     83                            <span class="exampleName" jugl:content="'(' + example.example + ')'">filename</span> 
     84                        </h3> 
     85                        <div class="ex_description" jugl:content="example.shortdesc"> 
     86                            Short Description goes here 
     87                        </div> 
     88                        <p class="ex_classes" jugl:content="example.classes"> 
     89                            Related Classes go here 
     90                        </p> 
    4091                    </a> 
    41                 </div> 
    42                 <div class="exampleDescription"> 
    43                     <span jugl:content="example.shortdesc"> 
    44                     Short Description goes here 
    45                     </span> 
    46                 </div> 
    47                 <div class="exampleClasses" > 
    48                     <span jugl:content="example.classes"> 
    49                     Related Classes go here 
    50                     </span> 
    5192                </div> 
    5293            </div>