jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r685201 [2/4] - in /incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs: ./ admin/ applets/ images/ scripts/ scripts/fckeditor/ scripts/json-rpc/
Date Tue, 12 Aug 2008 15:47:30 GMT
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/scripts/jspwiki-common.js
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/scripts/jspwiki-common.js?rev=685201&r1=685200&r2=685201&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/scripts/jspwiki-common.js (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/scripts/jspwiki-common.js Tue Aug 12 08:47:28 2008
@@ -1,54 +1,85 @@
-/**
- ** Javascript routines to support the BrushedTemplate
- ** Dirk Frederickx
- ** Nov 06-Mar 07: aligned with MooTools ##
- ** moo v1.1 selection needed:  
- **   Core, Class,  Native, Element(ex. Dimensions), Window,
- **   Effects(ex. Scroll), Drag(Base), Remote, Plugins(Hash.Cookie, Tips, Accordion)
- **
- ** 100 Wiki object (page parms, UserPrefs and setting focus) ##
- ** 110 WikiSlimbox : attachment viewer ##
- ** 114 Reflection (adds reflection to images) ##
- ** 120 QuickLinks object ##
- ** 130 TabbedSection object
- ** 132 Accordion object ##
- ** 140 SearchBox object: remember 10 most recent search topics
- ** 150 Colors, GraphBar object: e.g. used on the findpage
- ** 160 URL
- **
- ** 200 Collapsible list items
- ** 220 RoundedCorners ffs
- ** 230 Sortable (clever table-sort) ##
- ** 240 Table-filter (excel like table filters ##
- ** 250 Categories: turn wikipage link into AJAXed popup ##
- ** 260 WikiTips ##
- ** 270 WikiColumns ##
- ** 280 ZebraTable: color odd/even row of a table ##
- ** 290 HighlightWord: refactored
- ** 295 Typography
- ** 300 Prettify
- **/
+/* 
+    JSPWiki - a JSP-based WikiWiki clone.
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.  
+ */
+ 
+/*
+Javascript routines to support JSPWiki
+Since v.2.6.0
 
+Uses mootools v1.1, with following components:  
+*	Core, Class,  Native, Element(ex. Dimensions), Window,
+*	Effects(ex. Scroll), Drag(Base), Remote, Plugins(Hash.Cookie, Tips, Accordion)
+
+Core JS Routine
+*	100 Wiki object (page parms, UserPrefs and setting focus) 
+*	140 SearchBox object: remember 10 most recent search topics
+*	290 HighlightWords in the page-content
+
+Core Dynamic Styles
+	Wiki.addPageRender( XYZ )
+	Wiki.renderPage(page-element, page-name)
+
+*	110 WikiSlimbox (attachment viewer): dynamic style 
+*	130 TabbedSection object: dynamic style
+*	150 Colors, GraphBar object: dynamic style
+*	200 Collapsible list items: dynamic style
+*	230 Sortable: dynamic style 
+*	240 Table-filter (excel like column filters): dynamic style
+*	280 ZebraTable (color odd/even rows): dynmaic style
+
+Complementary Dynamic Styles (see jspwiki-commonstyles.js)
+*	114 Reflection (adds reflection to images): dynamic style 
+*	116 WikiCoverflow (based on MooFlow) : dynamic style
+*	118 Google Chart: dynamic style
+*	132 Accordion object: dynamic style
+*	220 RoundedCorners: dynamic style
+*	260 WikiTips: dynamic style 
+*	270 WikiColumns: dynamic style
+*	300 Prettify: dynamic style
+
+*/
 
 /* extend mootools */
 String.extend({
 	deCamelize: function(){
 		return this.replace(/([a-z])([A-Z])/g,"$1 $2");
+	},
+	trunc: function(size,elips){
+		if( !elips ) elips="...";
+		return (this.length<size) ? this : this.substring(0,size)+elips;
 	}
-});
-
+})
 
 // get text of a dhtml node
 function $getText(el) {
 	return el.innerText || el.textContent || '';
 }
 Element.extend({
+
 	/* wrapper = new Element('div').injectWrapper(node); */
-	injectWrapper: function(el){
+	wrapChildren: function(el){
 		while( el.firstChild ) this.appendChild( el.firstChild );
 		el.appendChild( this ) ;
 		return this;
 	},
+
 	visible: function() {
 		var el = this;
 		while($type(el)=='element'){
@@ -58,22 +89,24 @@
 		}
 		return true;
 	},
+
 	hide: function() {
-		this.style.display = 'none';
-		return this;
+		return this.setStyle('display','none');
 	},
+
 	show: function() {
-		this.style.display = '';
-		return this;
-	},	
+		return this.setStyle('display','');
+	},
+
 	toggle: function() {
-		this.visible() ? this.hide() : this.show();  
-		return this;
+		return this.visible() ? this.hide() : this.show();  
 	},
+
 	scrollTo: function(x, y){
 		this.scrollLeft = x;
 		this.scrollTop = y;
 	},
+
 	/* dimensions.js */
 	getPosition: function(overflown){
 		overflown = overflown || [];
@@ -88,7 +121,22 @@
 			top -= element.scrollTop || 0;
 		});
 		return {'x': left, 'y': top};
+	},
+
+	getDefaultValue: function(){
+		switch(this.getTag()){
+			case 'select':
+				var values = [];
+				$each(this.options, function(option){
+					if (option.defaultSelected) values.push($pick(option.value, option.text));
+				});
+				return (this.multiple) ? values : values[0];
+			case 'input': if (!(this.defaultChecked && ['checkbox', 'radio'].contains(this.type)) && !['hidden', 'text', 'password'].contains(this.type)) break;
+			case 'textarea': return this.defaultValue;
+		}
+		return false;
 	}
+
 });
 
 var Observer = new Class({
@@ -118,6 +166,7 @@
 		this.clear();
 	}
 });
+
 /* Observable class: observe any form element for changes */
 Element.extend({
 	observe: function(fn, options){
@@ -129,13 +178,17 @@
 /* I18N Support
  * LocalizedStrings takes form { "javascript.some.resource.key":"localised resource key {0}" }
  * Examples:
- * "javascript.moreInfo".localize();
- * "javascript.imageInfo".localize(2,4); => expects "Image {0} of {1}"
+ * "moreInfo".localize();
+ * "imageInfo".localize(2,4); => "Image {0} of {1}" becomes "Image 2 of 4 
  */
+var LocalizedStrings = LocalizedStrings || []; //defensive
 String.extend({
 	localize: function(){
-		var s = LocalizedStrings["javascript."+this], args = arguments;
+		var s = LocalizedStrings["javascript."+this], 
+			args = arguments;
+
 		if(!s) return("???" + this + "???");
+
 		return s.replace(/\{(\d)\}/g, function(m){ 
 			return args[m.charAt(1)] || "???"+m.charAt(1)+"???";
 		});
@@ -166,72 +219,107 @@
 /** 100 Wiki functions **/
 var Wiki = {
 
-	JSONid : 10000,
-	DELIM : '\u00A4',
-	init: function(props){
-		Object.extend(Wiki,props || {}); 
-		var h=location.host;
+	onPageLoad: function(){
+		if(this.prefs) return; //already initialised
+		//read all meta elements starting with wiki
+		$$('meta').each(function(el){
+			var n = el.getProperty('name') || '';
+			if( n.indexOf('wiki') == 0 ) this[n.substr(4)] = el.getProperty('content');
+		},this);
+
+		var h = location.host;
 		this.BasePath = this.BaseUrl.slice(this.BaseUrl.indexOf(h)+h.length,-1);
-		//this.ClientLanguage = navigator.language ? navigator.language : navigator.userLanguage;
-		//this.ClientTimezone = new Date().getTimezoneOffset()/60;
-		this.prefs=new Hash.Cookie('JSPWikiUserPrefs', {path:Wiki.BasePath, duration:20});
+
+		this.prefs = new Hash.Cookie('JSPWikiUserPrefs', {path:Wiki.BasePath, duration:20});
+		
+		this.PermissionEdit = !!$$('a.edit')[0]; //deduct permission level
+		this.url = null;
+		this.parseLocationHash.periodical(500);
+
+		this.makeMenuFx('morebutton', 'morepopup');
+		this.addEditLinks();
+
+		var p = $('page'); if(p) this.renderPage(p, Wiki.PageName);
+		var f = $('favorites'); if(f) this.renderPage(f, "Favorites");
+	},
+
+	renderPage: function(page, name){
+		this.$pageHandlers.each(function(obj){
+			obj.render(page, name)
+		});
+	},
+	addPageRender: function(fn){
+		if(!this.$pageHandlers) this.$pageHandlers = [];
+		this.$pageHandlers.push(fn);
+	},
+
+	setFocus: function(){
+		/* plain.jsp,   login.jsp,   prefs/profile, prefs/prefs, find */
+		['editorarea','j_username','loginname','assertedName','query2'].some(function(el){
+			el = $(el);
+			if(el && el.visible()) { el.focus(); return true; }
+			return false;
+		});
 	},
+
 	getUrl: function(pagename){
 		return this.PageUrl.replace(/%23%24%25/, pagename);
 	},	
+
 	/* retrieve pagename from any wikipage url format */
 	getPageName: function(url){
 		var s = this.PageUrl.escapeRegExp().replace(/%23%24%25/, '(.+)'),
 			res = url.match(new RegExp(s));
 		return (res ? res[1] : false);
 	},
-	onPageLoad: function(){
-		this.PermissionEdit = ($E('a.edit') !== undefined); //deduct permission level
-		this.url = null;
-		this.parseLocationHash.periodical(500);
 
-		/* plain.jsp,   login.jsp,   prefs/profile, prefs/prefs, find */
-		['editorarea','j_username','loginname','assertedName','query2'].some(function(el){
-			el = $(el);
-			if(el && el.visible()) { el.focus(); return true; }
-			return false;
-		});
-
-		if($('morebutton')) this.replaceMoreBox(); /* visual sugar */		
+	//ref com.ecyrd.jspwiki.parser.MarkupParser.cleanLink()
+	//trim repeated whitespace
+	//allow letters, digits and punctuation chars: ()&+,-=._$ 
+	cleanLink: function(p){
+		return p.trim().replace(/\s+/g,' ')
+				.replace(/[^A-Za-z0-9()&+,-=._$ ]/g, '');
 	},
+
 	savePrefs: function(){
-		if($('prefSkin')) this.prefs.set('SkinName', $('prefSkin').getValue());
-		if($('prefTimeZone')) this.prefs.set('TimeZone', $('prefTimeZone').getValue());
-		if($('prefTimeFormat')) this.prefs.set('DateFormat', $('prefTimeFormat').getValue());
-		if($('prefOrientation')) this.prefs.set('orientation', $('prefOrientation').getValue());
-		if($('editor')) this.prefs.set('editor', $('editor').getValue()); 
-		this.prefs.set('FontSize',this.PrefFontSize);
+		var prefs = {
+			'prefSkin':'SkinName',
+			'prefTimeZone':'TimeZone',
+			'prefTimeFormat':'DateFormat',
+			'prefOrientation':'Orientation',
+			'editor':'editor',
+			'prefLanguage':'Language',
+			'prefSectionEditing':'SectionEditing'
+		};
+		for(el in prefs){
+			if($(el)) this.prefs.set(prefs[el],$(el).getValue());
+		};
 	},
 
 	changeOrientation: function(){
-		$('wikibody').className = $('prefOrientation').getValue();
-	},
-	replaceMoreBox: function(){
-		var more = $('morebutton'),
-			popup = new Element('ul').inject(more), 
-			hover = popup.effect('opacity', {wait:false}).set(0),
-			select = $('actionsMore'),
-			separator = '';
-
-		$A(select.options).each(function(o){
-			if(o.value == "") return;
-			separator='separator';
-			new Element('a',{'class':o.className,'href':o.value})
-				.setHTML(o.text).inject(new Element('li').inject(popup));
+		var fav = $('prefOrientation').getValue();
+		$('wikibody')
+			.removeClass('fav-left').removeClass('fav-right')
+			.addClass(fav);
+		//$('collapseFavs').fireEvent('click').fireEvent('click'); //refresh sliding favorites
+	},
+
+	/* make hover menu with fade effect */
+	makeMenuFx: function(btn, menu){
+		var btn = $(btn), menu = $(menu);
+		if(!btn || !menu) return;
+
+		var	popfx = menu.effect('opacity', {wait:false}).set(0);
+		btn.adopt(menu).set({
+			'href':'#',
+			'events':{
+				'mouseout': function(){ popfx.start(0) },
+				'mouseover': function(){ Wiki.locatemenu(btn,menu); popfx.start(0.9) }
+			}
 		});
-		$('moremenu').inject(new Element('li',{'class':separator}).inject(popup));
-		
-		select.getParent().hide();
-		more.show()
-		 	.addEvent('mouseout',(function(){ hover.start(0) }).bind(this))
-			.addEvent('mouseover',(function(){ Wiki.locatemenu(more,popup); hover.start(0.9) }).bind(this));
 	},
-
+	
+	//FIXME
 	locatemenu: function(base,el){
 		var win = {'x': window.getWidth(), 'y': window.getHeight()},
 			scroll = {'x': window.getScrollLeft(), 'y': window.getScrollTop()},
@@ -255,14 +343,13 @@
 		h = h.replace(/^#/,'');
 
 		var el = $(h);
-
 		while( $type(el) == 'element' ){
 			if( el.hasClass('hidetab') ){
-				TabbedSection.clickTab.apply(el);
+				TabbedSection.click.apply($('menu-'+el.id));
 			} else if( el.hasClass('tab') ){
-				/* accordion -- need to find accordion object */
+				/* accordion -- need to find accordion toggle object */
 			} else if( el.hasClass('collapsebody') ){
-				/* collapsible box */
+				/* collapsible box -- need to find the toggle button */
 			} else if(!el.visible() ){
 				//alert('not visible'+el.id);
 				//fixme need to find the correct toggler
@@ -273,12 +360,22 @@
 
 		location = location.href; /* now jump to the #hash */
 	},
+	
+	alert: function(msg){
+		/* TODO: create popup alert, which allowed any html msg to be displayed */
+		alert(msg);
+	},
+
+	prompt: function(title, msg){
+		/* TODO: create popup prompt */
+		return prompt(title,msg);
+	},
 
 	/* SubmitOnce: disable all buttons to avoid double submit */
 	submitOnce: function(form){
 		window.onbeforeunload = null; /* regular exit of this page -- see jspwiki-edit.js */
 		(function(){ 
-		$A(form.elements).each(function(e){
+			$A(form.elements).each(function(e){
 				if( (/submit|button/i).test(e.type)) e.disabled = true;
 			});
 		}).delay(10);
@@ -295,16 +392,32 @@
 		return Wiki.submitOnce(form);
 	},
 
-	JSONid : 10000,
+	addEditLinks: function(){
+		if( $("previewcontent") || !this.PermissionEdit || this.prefs.get('SectionEditing') != 'on') return;
+
+		var url = this.EditUrl;
+		url = url + (url.contains('?') ? '&' : '?') + 'section=';
+
+		var aa = new Element('a').setHTML('quick.edit'.localize()), 
+			ee = new Element('span',{'class':'editsection'}).adopt(aa);
+
+		$$('#pagecontent *[id^=section]').each(function(el,i){
+			aa.set({'href':url+i});
+			el.adopt(ee.clone());
+		});
+	},
+
+	$jsonid : 10000,
 	jsonrpc: function(method, params, fn) {	
 		new Ajax( Wiki.JsonUrl, {
-			postBody: Json.toString({"id":Wiki.JSONid++, "method":method, "params":params}), 
+			postBody: Json.toString({"id":Wiki.$jsonid++, "method":method, "params":params}), 
 			method: 'post', 
 			onComplete: function(result){ 
 				var r = Json.evaluate(result,true);
-				if(!r) return;
-				if(r.result) fn(r.result);
-				else if(r.error) fn(r.error);
+				if(r){
+					if(r.result){ fn(r.result) }
+					else if(r.error){ fn(r.error) }
+				}
 			}
 		}).request();
 	}	
@@ -313,32 +426,35 @@
 
 /** 110 WikiSlimbox
  ** Inspired http://www.digitalia.be/software/slimbox by Christophe Bleys
- ** Dirk Frederickx, Mar 2007
  ** 	%%slimbox [...] %%
  ** 	%%slimbox-img  [some-image.jpg] %%
  ** 	%%slimbox-ajax [some-page links] %%
  **/
 var WikiSlimbox = {
 
-	onPageLoad: function(){
+	render: function(page, name){
 		var i = 0,
 			lnk = new Element('a',{'class':'slimbox'}).setHTML('&raquo;');
 			
-		$$('*[class^=slimbox]').each(function(slim){
+		$ES('*[class^=slimbox]',page).each(function(slim){
 			var group = 'lightbox'+ i++,
 				parm = slim.className.split('-')[1] || 'img ajax',
 				filter = [];
 			if(parm.test('img')) filter.extend(['img.inline', 'a.attachment']); 
 			if(parm.test('ajax')) filter.extend(['a.wikipage', 'a.external']); 
+
 			$ES(filter.join(','),slim).each(function(el){
-				var href = el.src||el.href;
-				var rel = (el.className.test('inline|attachment')) ? 'img' : 'ajax';
+				var href = el.src||el.href,
+					rel = (el.className.test('inline|attachment')) ? 'img' : 'ajax';
+
 				if((rel=='img') && !href.test('(.bmp|.gif|.png|.jpg|.jpeg)(\\?.*)?$','i')) return;
+
 				lnk.clone().setProperties({
 					'href':href, 
 					'rel':group+' '+rel,
 					'title':el.alt||el.getText()
 				}).injectBefore(el);
+
 				if(el.src) el.replaceWith(new Element('a',{
 					'class':'attachment',
 					'href':el.src
@@ -346,9 +462,10 @@
 			});
 		});
 		if(i) Lightbox.init();
-		//new Asset.javascript(Wiki.TemplateDir+'scripts/slimbox.js');
+		//new Asset.javascript(Wiki.TemplateUrl+'scripts/slimbox.js');
 	}
 }
+Wiki.addPageRender(WikiSlimbox);
 
 /*
 	Slimbox v1.31 - The ultimate lightweight Lightbox clone
@@ -607,114 +724,12 @@
 		for (var f in this.fx) this.fx[f].stop();
 		this.center.style.display = this.bottomContainer.style.display = 'none';
 		this.fx.overlay.chain(this.setup.pass(false, this)).start(0);
+		this.image.empty();
 		return false;
 	}
 };
 
 
-/** 114 Reflection
- ** Inspired by Reflection.js at http://cow.neondragon.net/stuff/reflection/
- ** Freely distributable under MIT-style license.
- ** Adapted for JSPWiki/BrushedTemplate, D.Frederickx, Sep 06
- ** Use:
- ** 	%%reflection-height-opacity  [some-image.jpg] %%
- **/
-var WikiReflection = {
-
-	onPageLoad: function(){
-		$$('*[class^=reflection]').each( function(w){
-			var parms = w.className.split('-');
-			$ES('img',w).each(function(img){
-				Reflection.add(img, parms[1], parms[2]);
-			}); 
-		});
-	}
-}
-/* FIXME : add delayed loading of reflection library */
-var Reflection = {
-
-	options: { height: 0.33, opacity: 0.5 },
-
-	add: function(img, height, opacity) {
-		//TODO Reflection.remove(image); --is this still needed?
-		height  = (height ) ? height/100 : this.options.height;
-		opacity = (opacity) ? opacity/100: this.options.opacity;
-
-		var div = new Element('div').injectAfter(img).adopt(img),
-			imgW = img.width,
-			imgH = img.height,
-			rH   = Math.floor(imgH * height); //reflection height
-
-		div.className = img.className.replace(/\breflection\b/, "");
-		div.style.cssText = img.backupStyle = img.style.cssText;
-		//div.setStyles({'width':img.width, 'height':imgH +rH, "maxWidth": imgW });
-		div.setStyles({'width':img.width, 'height':imgH +rH });
-		img.style.cssText = 'vertical-align: bottom';
-		//img.className = 'inline reflected';  //FIXME: is this still needed ??
-
-		if( window.ie ){ 
-			new Element('img', {'src': img.src, 'styles': {
-				'width': imgW,
-				'marginBottom': "-" + (imgH - rH) + 'px',
-				'filter': 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(opacity*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(height*100)+')'
-			}}).inject(div);
-		} else {
-			var r = new Element('canvas', {'width':imgW, 'height':rH, 'styles': {'width':imgW, 'height': rH}}).inject(div);
-			if( !r.getContext ) return;
-
-			var ctx = r.getContext("2d");
-			ctx.save();
-			ctx.translate(0, imgH-1);
-			ctx.scale(1, -1);
-			ctx.drawImage(img, 0, 0, imgW, imgH);
-			ctx.restore();
-			ctx.globalCompositeOperation = "destination-out";
-
-			var g = ctx.createLinearGradient(0, 0, 0, rH);
-			g.addColorStop( 0, "rgba(255, 255, 255, " + (1 - opacity) + ")" );
-			g.addColorStop( 1, "rgba(255, 255, 255, 1.0)" );
-			ctx.fillStyle = g;
-			ctx.rect( 0, 0, imgW, rH );
-			ctx.fill(); 
-		}
-	}
-}
- 
-/** 120 brushed quick links **/
-var QuickLinks = {
-
-	onPageLoad: function(){
-		if( $("previewcontent") || !Wiki.PrefShowQuickLinks ) return;
-
-		var sections = $$('#pagecontent *[id^=section]');
-		if(sections.length==0) return;
-		
-		var ql,qlPrev,qlEdit,qlNext;
-		function qql(clazz,title,text,href){
-			var a = new Element('a',{'title':title.localize()}).setHTML(text);
-			if(href) a.setProperty('href',href);
-			ql.adopt(new Element('span',{'class':clazz}).adopt(a));
-			return(a);
-		}
-		ql = new Element('div',{'class':'quicklinks'});
-		qql('quick2Top','quick.top','&laquo;','#wikibody');
-		qlPrev = qql('quick2Prev','quick.previous','&lsaquo;');
-
-		if(Wiki.PermissioneEdit) qlEdit = qql('quick2Edit','quick.edit','&bull;');
-
-		qlNext = qql('quick2Next','quick.next','&rsaquo;');
-		qql('quick2Bottom','quick.bottom','&raquo;','#footer');
-				
-		var last = sections.length-1;
-		sections.each(function(s,i){
-			qlNext.setProperty('href',(i==last) ? '#footer' : '#'+sections[i+1].id);
-			qlPrev.setProperty('href',(i==0) ? '#wikibody' : '#'+sections[i-1].id);
-			if(qlEdit) qlEdit.setProperty('href','Edit.jsp?page='+Wiki.PageName+'&section='+(i+1));
-			s.adopt(ql.clone());
-		});
-	}
-}
-
 /** Class: Tabbed Section (130)
 	Creates tabs, based on some css-class information
 	Use in jspwiki: %%tabbedSection  %%tab-FirstTab .. %% %%
@@ -734,115 +749,55 @@
  **/
 var TabbedSection = {
 
-	onPageLoad: function(){
-
-		// charge existing tabmenu's with click handlers
-		$$('.tabmenu a').each(function(el){
-			if(el.href) return;
-			var tab = $(el.id.substr(5)); //drop 'menu-' prefix
-			el.addEvent('click', this.clickTab.bind(tab) );
+	render: function(page, name){
+		// add click handlers to existing tabmenu's, generated by <wiki:tabbedSection>
+		$ES('.tabmenu a',page).each(function(el){
+			if(!el.href) el.addEvent('click', this.click);
 		},this);	
 	
 		// convert tabbedSections into tabmenu's with click handlers
-		$$('.tabbedSection').each( function(tt){
-			tt.addClass('tabs'); //css styling is on tabs
-			var tabmenu = new Element('div',{'class':'tabmenu'}).injectBefore(tt);
+		$ES('.tabbedSection',page).each( function(tt){
+			if(tt.hasClass('tabs')) return;
+			tt.addClass('tabs'); //css styling on tabs
+			
+			var menu = new Element('div',{'class':'tabmenu'}).injectBefore(tt);
 
 			tt.getChildren().each(function(tab,i) {
-				if( !tab.className.test('^tab-') ) return;
+				//find nested %%tab-XXX
+				var clazz = tab.className;
+				if( !clazz.test('^tab-') ) return; 
 
-				if( !tab.id || (tab.id=="") ) tab.id = tab.className;
-				var title = tab.className.substr(4).deCamelize(); //drop 'tab-' prefix
+				if( !tab.id || (tab.id=="") ) tab.id = clazz; //unique id
 
 				(i==0) ? tab.removeClass('hidetab') : tab.addClass('hidetab');
 
-				new Element('div',{'styles':{'clear':'both'}}).inject(tab);
+				new Element('div',{'class':'clearbox'}).inject(tab);
 
-				var menu = new Element('a', {
+				var title = clazz.substr(4).deCamelize(); //drop 'tab-' prefix
+				new Element('a', {
 					'id':'menu-'+tab.id, 
-					'events':{ 'click': this.clickTab.bind(tab)  }
-				}).appendText(title).inject(tabmenu);
-				if( i==0 ) menu.addClass('activetab');        
+					'class':(i==0) ? 'activetab' : '',
+					'events':{ 'click': this.click }
+				}).appendText(title).inject(menu);
+
 			},this);
 		}, this);
 	},
 
-	clickTab: function(){
-		var menu = $('menu-'+this.id);
-		this.getParent().getChildren().some( function(el){
-			if(el.id){
-				var m = $('menu-'+el.id);
-				if( m && m.hasClass('activetab') ) {
-					if( el.id != this.id ) {
-						m.removeClass('activetab');      
-						menu.addClass('activetab');
-						el.addClass('hidetab');
-						this.removeClass('hidetab'); //.show();
-					}
-					return true;
-				}
-			}
-			return false;
-		},this);		
-	}
-	
-}
-
-/** 132 Accordion for Tabs, Accordeons, CollapseBoxes
- **
- ** Following markup:
- ** <div class="accordion">
- **		<div class="tab-FirstTab">...<div>
- **		<div class="tab-SecondTab">...<div>
- ** </div>
- **
- **	is changed into
- **	<div class="accordion">
- **		<div class="toggle active">First Tab</div>
- **		<div class="tab-FirstTab tab active">...</div>
- **		<div class="toggle">Second Tab</div>
- **		<div class="tab-SecondTab">...</div>
- **	</div>
- **/
-var WikiAccordion = {
-
-	onPageLoad: function(){
-		$$('.accordion, .tabbedAccordion').each( function(tt){
-			
-			var toggles=[], contents=[], togglemenu=false;
-			if(tt.hasClass('tabbedAccordion')) togglemenu = new Element('div',{'class':'togglemenu'}).injectBefore(tt);
+	click: function(){
+		var menu = $(this).getParent(),
+			tabs = menu.getNext();
 			
-			tt.getChildren().each(function(tab) {
-				if( !tab.className.test('^tab-') ) return;
+		menu.getChildren().removeClass('activetab');
+		this.addClass('activetab');
 
-				//FIXME use class to make tabs visible during printing 
-				//(i==0) ? tab.removeClass('hidetab'): tab.addClass('hidetab');
-
-				var title = tab.className.substr(4).deCamelize();
-				if(togglemenu) {
-					toggles.push(new Element('div',{'class':'toggle'}).inject(togglemenu).appendText(title));
-				} else {
-					toggles.push(new Element('div',{'class':'toggle'}).injectBefore(tab).appendText(title));
-				}        
-				contents.push(tab.addClass('tab'));
-			});
-			new Accordion(toggles, contents, {     
-				alwaysHide: !togglemenu,
-				onComplete: function(){
-					var el = $(this.elements[this.previous]);
-					if (el.offsetHeight > 0) el.setStyle('height', 'auto');  
-				},
-				onActive: function(toggle,content){                          
-					toggle.addClass('active'); content.addClass('active'); 
-				},
-				onBackground: function(toggle,content){ 
-					content.setStyle('height', content['offsetHeight']);
-					toggle.removeClass('active'); content.removeClass('active');
-				} 
-			});
-		});
+		tabs.getChildren().addClass('hidetab');
+		tabs.getElementById(this.id.substr(5)).removeClass('hidetab');		
 	}
+	
 }
+Wiki.addPageRender(TabbedSection);
+
 
 
 /* 140 SearchBox
@@ -872,9 +827,9 @@
 			  .addEvent('mouseover',function(){ Wiki.locatemenu(this.query, $('searchboxMenu') ); this.hover.start(0.9) }.bind(this));
 		
 		/* use advanced search-input on safari - experimental */
-		if(window.xwebkit){
-			q.setProperties({type:"search",autosave:q.form.action,results:"9",placeholder:q.defaultValue});
-		} else {
+		//if(window.webkit){
+		//	q.setProperties({type:"search",autosave:q.form.action,results:"9",placeholder:q.defaultValue});
+		//} else {
 			$('recentClear').addEvent('click', this.clear.bind(this));
 
 			this.recent = Wiki.prefs.get('RecentSearch'); if(!this.recent) return;
@@ -886,7 +841,7 @@
 					'events': {'click':function(){ q.value = el; q.form.submit(); }}
 					}).setHTML(el).inject( new Element('li').inject(ul) );
 			});
-		}
+		//}
 	},
 
 	onPageLoadFullSearch : function(){
@@ -919,11 +874,15 @@
 			if (option.value == match) option.selected = true;
 		});
 
-		new Ajax(Wiki.TemplateDir+'AJAXSearch.jsp', {
+		new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
 			postBody: $('searchform2').toQueryString(),
 			update: 'searchResult2', 
 			method: 'post',
-			onComplete: function() { $('spin').hide(); GraphBar.onPageLoad(); Wiki.prefs.set('PrevQuery', q2); } 
+			onComplete: function() { 
+				$('spin').hide(); 
+				GraphBar.render($('searchResult2')); 
+				Wiki.prefs.set('PrevQuery', q2); 
+			} 
 		}).request();
 	},
 
@@ -969,21 +928,42 @@
 		});
 	} ,
 
-
 	/* navigate to url, after smart pagename handling */
 	navigate: function(url, promptText, clone, search){
-		var p = Wiki.PageName, s = this.query.value;
+		var p = Wiki.PageName,
+			defaultResult = (clone) ? p+'sbox.clone.suffix'.localize() : p,
+			s = this.query.value;			
 		if(s == this.query.defaultValue) s = '';
 
-		if(s == ''){
-			s = prompt(promptText, (clone) ? p+'sbox.clone.suffix'.localize() : p);
-			if( !s || (s == '') ) return false;
-		}
-		//if(!search) s = s.replace(/[^A-Za-z0-9._\/]/g, ''); //valid pagename FIXME
-		if( clone && (s != p) )  s += '&clone=' + p;
+		var handleResult=function(s){
+			if(s == '') return;
+			if(!search)	s = Wiki.cleanLink(s);//remove invalid chars from the pagename
+		
+			p=encodeURIComponent(p);
+			s=encodeURIComponent(s);
+			if(clone && (s != p)) s += '&clone=' + p;
 
-		if(s == '') return false; //dont exec the click
-		location.href = url.replace('__PAGEHERE__', s);
+			location.href = url.replace('__PAGEHERE__', s );
+		};
+		
+		if(s!='') handleResult(s); //????
+		//handleResult(Wiki.prompt(promptText, (clone) ? p+'sbox.clone.suffix'.localize() : p));
+		//return;
+
+		Wiki.prompt(promptText, defaultResult, handleResult.bind(this));
+
+		return;
+/*		
+		new Popup({
+			caption:'',
+			body:promptText,
+			promptDefault:(clone) ? p+'sbox.clone.suffix'.localize() : p,
+			buttons:({
+				'Cancel':Class.empty,
+				'Ok':function(result){ doNavigate(result); }
+			})
+		});
+*/
 	}
 }
 
@@ -1013,6 +993,7 @@
 	},
 	
 	initialize: function(color, type){
+		if(!color) return false;
 		type = type || (color.push ? 'rgb' : 'hex');
 		if(this._HTMLColors[color]) color = this._HTMLColors[color];
 		var rgb = (type=='rgb') ? color : color.toString().hexToRgb(true);
@@ -1044,8 +1025,8 @@
 
 var GraphBar =
 {
-	onPageLoad : function(){
-		$$('*[class^=graphBars]').each( function(g){
+	render: function(page, name){
+		$ES('*[class^=graphBars]',page).each( function(g){
 			var lbound = 20,	//max - lowerbound size of bar
 				ubound = 320,	//min - upperbound size of bar
 				vwidth = 20,	//vertical bar width
@@ -1097,7 +1078,7 @@
 						bar1.set(border+'Width',ubound-barData[j]).set('marginLeft','-1ex'); 
 					}					
 				} else { // isVertical
-					if(pb.getTag()=='td') { pb = new Element('div').injectWrapper(pb); }
+					if(pb.getTag()=='td') { pb = new Element('div').wrapChildren(pb); }
 
 					pb.setStyles({'height':ubound+b.getStyle('lineHeight').toInt(), 'position':'relative'});
 					b.setStyle('position', 'relative'); //needed for inserted spans ;-)) hehe
@@ -1122,6 +1103,7 @@
 				
 				if(bar2.length > 0){ barEL.clone().setStyles(bar2.obj).injectBefore(b); };
 				if(bar1.length > 0){ barEL.setStyles(bar1.obj).injectBefore(b); };
+
 			},this);
 
 		},this);
@@ -1171,7 +1153,7 @@
 				if( $getText( r.cells[h] ).trim() == fieldName ){
 					var result = [];
 					for( var i=1; i< tlen; i++)
-						result.push( new Element('span').injectWrapper(table.rows[i].cells[h]) );
+						result.push( new Element('span').wrapChildren(table.rows[i].cells[h]) );
 					return result;
 				}
 			}
@@ -1181,44 +1163,37 @@
 			if( $getText( r.cells[0] ).trim() == fieldName ){
 				var result = [];
 				for( var i=1; i< r.cells.length; i++)
-					result.push( new Element('span').injectWrapper(r.cells[i]) );
+					result.push( new Element('span').wrapChildren(r.cells[i]) );
 				return result;
 			}
 		}
 		return false;
 	}
 }
+Wiki.addPageRender(GraphBar);
 
-/** 200 Collapsible list and boxes
- ** See also David Lindquist <first name><at><last name><dot><net>
- ** See: http://www.gazingus.org/html/DOM-Scripted_Lists_Revisited.html
- **
- ** Add support for collabsable boxes, Nov 05, D.Frederickx
- ** Refactored on mootools, including effects, May 07, D.Frederickx
- **/
+
+/** 200 Collapsible list and boxes **/
 var Collapsible =
 {
 	pims : [], // all me cookies
 
-	onPageLoad: function(){
-		this.bullet = new Element('div',{'class':'collapseBullet'}).setHTML('&bull;');
-		this.initialise( "favorites",   "JSPWikiCollapseFavorites" );
-		this.initialise( "pagecontent", "JSPWikiCollapse" + Wiki.PageName );
-		this.initialise( "previewcontent", "JSPWikiCollapse" + Wiki.PageName );
-		this.initialise( "info" );
-	},
-
-	initialise: function( page, cookie){
+	render: function(page, name){
 		page = $(page); if(!page) return;
 
+		var cookie = Wiki.Context.test(/view|edit|comment/) ? "JSPWikiCollapse"+ name: "";
+
+		if(!this.bullet) {
+			this.bullet = new Element('div',{'class':'collapseBullet'}).setHTML('&bull;');		
+		}
+
 		this.pims.push({
 			'name':cookie,
 			'value':'',
 			'initial': (cookie ? Cookie.get(cookie) : "") 
 		});
 		$ES('.collapse', page).each(function(el){ 
-			if( $E('.collapseBullet',el) ) return; /* no nesting */
-			this.collapseNode(el); 
+			if(!$E('.collapseBullet',el)) this.collapseNode(el); // no nesting
 		}, this);
 		$ES('.collapsebox,.collapsebox-closed', page).each(function(el){ 
 			this.collapseBox(el); 
@@ -1226,14 +1201,16 @@
 	},
 
 	collapseBox: function(el){
+		if($E('.collapsetitle',el)) return; //been here before
 		var title = el.getFirst(); if( !title ) return;
+		
 		var body = new Element('div', {'class':'collapsebody'}), 
 			bullet  = this.bullet.clone(),
 			isclosed = el.hasClass('collapsebox-closed');
 
 		while(title.nextSibling) body.appendChild(title.nextSibling); // wrap other siblings
 		el.appendChild(body);
-		
+
 		if(isclosed) el.removeClass('collapsebox-closed').addClass('collapsebox');
 		bullet.injectTop( title.addClass('collapsetitle') );
 		this.newBullet(bullet, body, !isclosed, title );
@@ -1256,7 +1233,7 @@
 			}
 			if( emptyLI ) return;
 			
-			new Element('div',{'class':'collapsebody'}).injectWrapper(li);
+			new Element('div',{'class':'collapsebody'}).wrapChildren(li);
 			var bullet = this.bullet.clone().injectTop(li);
 			if(ulol) this.newBullet(bullet, ulol, (ulol.getTag()=='ul'));
 		},this);
@@ -1276,11 +1253,11 @@
 
 		bullet.className = (isopen ? 'collapseClose' : 'collapseOpen'); //ready for rendering
 		clicktarget.addEvent('click', this.clickBullet.bind(bullet, [ck, ck.value.length-1, bodyfx]))
-			.addEvent('mouseenter', function(){ clicktarget.addClass('collapseHover')} )
-			.addEvent('mouseleave', function(){ clicktarget.removeClass('collapseHover')} );
+			.addEvent('mouseenter', function(){ clicktarget.addClass('hover')} )
+			.addEvent('mouseleave', function(){ clicktarget.removeClass('hover')} );
 			  
 		bodyfx.fireEvent('onStart');
-		if(!isopen) bodyfx.set(0); //.set( isopen ? body.scrollHeight : 0 );	
+		if(!isopen) bodyfx.set(0);	
 	},
 
 	renderBullet: function(){
@@ -1320,210 +1297,30 @@
 
 		return(token == 'o');
 	}
-}
-
-
-/** 220 RoundedCorners --experimental
- ** based on Nifty corners by Allesandro Fulciniti
- ** www.pro.html.it
- ** Refactored for JSPWiki
- **
- ** JSPWiki syntax:
- **
- **  %%roundedCorners-<corners>-<color>-<borderColor>
- **  %%
- **
- **  roundedCorners-yyyy-ffc5ff-c0c0c0
- **
- **  corners: "yyyy" where first y: top-left,    2nd y: top-right,
- **                           3rd y: bottom-left; 4th y: bottom-right
- **     value can be: "y": Normal rounded corner (lowercase y)
- **                    "s": Small rounded corner (lowercase s)
- **                    "n": Normal square corner
- **
- **/
-var RoundedCorners =
-{
-	/** Definition of CORNER dimensions
-	 ** Normal    Normal+Border  Small  Small+Border
-	 ** .....+++  .....BBB       ..+++  ..BBB
-	 ** ...+++++  ...BB+++       .++++  .B+++
-	 ** ..++++++  ..B+++++       +++++  B++++
-	 ** .+++++++  .B++++++
-	 ** .+++++++  .B++++++
-	 ** ++++++++  B+++++++
-	 **
-	 ** legend: . background, B border, + forground color
-	 **/
-	NormalTop :
-		 [ { margin: "5px", height: "1px", borderSide: "0", borderTop: "1px" }
-		 , { margin: "3px", height: "1px", borderSide: "2px" }
-		 , { margin: "2px", height: "1px", borderSide: "1px" }
-		 , { margin: "1px", height: "2px", borderSide: "1px" }
-		 ] ,
-	SmallTop :
-		 [ { margin: "2px", height: "1px", borderSide: "0", borderTop: "1px" }
-		 , { margin: "1px", height: "1px", borderSide: "1px" }
-		 ] ,
-	//NormalBottom: see onPageLoad()
-	//SmallBottom: see onPageLoad()
-
-	/**
-	 ** Usage:
-	 ** RoundedCorners.register( "#header", ['yyyy', '00f000', '32cd32'] );
-	 **/
-	registry: {},
-	register: function( selector, parameters )
-	{
-		this.registry[selector] = parameters;
-		return this;
-	},
-
-	onPageLoad: function()
-	{
-		/* make reverse copies for bottom definitions */
-		this.NormalBottom = this.NormalTop.slice(0).reverse();
-		this.SmallBottom  = this.SmallTop.slice(0).reverse();
-
-		for( selector in this.registry )  // CHECK NEEDED
-		{
-			var n = $$(selector); 
-			var parms = this.registry[selector];
-			this.exec( n, parms[0], parms[1], parms[2], parms[3] );
-		}
-
-		$$('#pagecontent *[class^=roundedCorners]').each(function(el){ 
-			var parms = el.className.split('-');
-			if( parms.length < 2 ) return;
-			this.exec( [el], parms[1], parms[2], parms[3], parms[4] );
-		},this);
-	},
-
-	exec: function( nodes, corners, color, borderColor, background )
-	{
-		corners = ( corners ? corners+"nnnn": "yyyy" );
-		color   = new Color(color,'hex') || 'transparent';
-		if(borderColor) borderColor = new Color(borderColor);
-		if(background)  background  = new Color(background);
-
-		var c = corners.split('');
-		/* [0]=top-left; [1]=top-right; [2]=bottom-left; [3]=bottom-right; */
-
-		var nodeTop = null;
-		var nodeBottom = null;
-
-		if( c[0]+c[1] != "nn" )  //add top rounded corners
-		{
-			nodeTop = document.createElement("b") ;
-			nodeTop.className = "roundedCorners" ;
-
-			if( (c[0] == "y") || (c[1] == "y") )
-			{
-				this.addCorner( nodeTop, this.NormalTop, c[0], c[1], color, borderColor );
-			}
-			else if( (c[0] == "s") || (c[1] == "s") )
-			{
-				this.addCorner( nodeTop, this.SmallTop, c[0], c[1], color, borderColor );
-			}
-		}
-
-		if( c[2]+c[3] != "nn" ) //add bottom rounded corners
-		{
-			nodeBottom = document.createElement("b");
-			nodeBottom.className = "roundedCorners";
-
-			if( (c[2] == "y") || (c[3] == "y") )
-			{
-				this.addCorner( nodeBottom, this.NormalBottom, c[2], c[3], color, borderColor );
-			}
-			else if( (c[2] == "s") || (c[3] == "s") )
-			{
-				this.addCorner( nodeBottom, this.SmallBottom, c[2], c[3], color, borderColor );
-			}
-		}
-
-		if( (!nodeTop) && (!borderColor) && (!nodeBottom) ) return;
-
-		for( var i=0; i<nodes.length; i++)
-		{
-			if( !nodes[i] ) continue;
-			this.addBody( nodes[i], color, borderColor );
-			if( nodeTop     )  nodes[i].insertBefore( nodeTop.cloneNode(true), nodes[i].firstChild );
-			if( nodeBottom  )  nodes[i].appendChild( nodeBottom.cloneNode(true) );
-		}
-	},
-
-	addCorner: function( node, arr, left, right, color, borderColor )
-	{
-		for( var i=0; i< arr.length; i++ )
-		{
-			var n =  document.createElement("div");
-			n.style.height = arr[i].height;
-			n.style.overflow = "hidden";
-			n.style.borderWidth = "0";
-			n.style.backgroundColor = color.hex;
-
-			if( borderColor )
-			{
-				n.style.borderColor = borderColor.hex;
-				n.style.borderStyle = "solid";
-				if(arr[i].borderTop)
-				{
-					n.style.borderTopWidth = arr[i].borderTop;
-					n.style.height = "0";
-				}
-			}
-
-			if( left != 'n' ) n.style.marginLeft = arr[i].margin;
-			if( right != 'n' ) n.style.marginRight = arr[i].margin;
-			if( borderColor )
-			{
-				n.style.borderLeftWidth  = ( left  == 'n' ) ? "1px": arr[i].borderSide;
-				n.style.borderRightWidth = ( right == 'n' ) ? "1px": arr[i].borderSide;
-			}
-			node.appendChild( n );
-		}
-	},
-
-	// move all children of the node inside a DIV and set color and bordercolor
-	addBody: function( node, color, borderColor)
-	{
-		if( node.passed ) return;
-
-		var container = new Element('div').injectWrapper(node);
-
-		container.style.padding = "0 4px";
-		container.style.backgroundColor = color.hex;
-		if( borderColor )
-		{
-			container.style.borderLeft  = "1px solid " + borderColor.hex;
-			container.style.borderRight = "1px solid " + borderColor.hex;
-		}
-
-		node.passed=true;
-	}
-}
+};
+Wiki.addPageRender(Collapsible);
 
 
 /** 230 Sortable -- Sort tables **/
 //TODO cache table ok, cache datatype for each column
 var Sortable =
 {
-	onPageLoad: function(){
+	render: function(page,name){
 		this.DefaultTitle = "sort.click".localize();
 		this.AscendingTitle = "sort.ascending".localize();
 		this.DescendingTitle = "sort.descending".localize();
 		
-		$$('.sortable table').each(function(table){
+		$ES('.sortable table',page).each(function(table){
 			if( table.rows.length < 2 ) return;
 
 			$A(table.rows[0].cells).each(function(th){
 				th=$(th);
-				if( th.getTag() != 'th' ) return;
-				th.addEvent('click', function(){ Sortable.sort(th); })
-					.addClass('sort')
-					.title=Sortable.DefaultTitle;
-			});
+				if(th.getTag()=='th'){
+					th.addEvent('click', this.sort.bind(this,[th]) )
+						.addClass('sort')
+						.title=this.DefaultTitle;
+				}
+			},this);
 		},this);
 	},
 
@@ -1571,15 +1368,16 @@
 	},
 
 	guessDataType: function(rows, colidx){
-		var num=date=ip4=euro=true;
+		var num=date=ip4=euro=kmgt=true;
 		rows.each(function(r,i){
 			var v = $getText(r.cells[colidx]).clean().toLowerCase();
 			if(num)  num  = !isNaN(parseFloat(v));
 			if(date) date = !isNaN(Date.parse(v));
-			if(ip4)  ip4  = v.test("(?:\\d{1,3}\\.){3}\\d{1,3}");
-			if(euro) euro = v.test("^[£$€][0-9.,]+");
+			if(ip4)  ip4  = v.test(/(?:\\d{1,3}\\.){3}\\d{1,3}/); //169.169.0.1
+			if(euro) euro = v.test(/^[£$€][0-9.,]+/);
+			if(kmgt) kmgt = v.test(/(?:[0-9.,]+)\s*(?:[kmgt])b/);  //2 MB, 4GB, 1.2kb, 8Tb
 		});
-		return (euro) ? 'euro': (ip4) ? 'ip4': (date) ? 'date': (num) ? 'num': 'string';
+		return (kmgt) ? 'kmgt': (euro) ? 'euro': (ip4) ? 'ip4': (date) ? 'date': (num) ? 'num': 'string';
 	},
 
 	convert: function(val, datatype){
@@ -1590,7 +1388,13 @@
 			case "ip4" : 
 				var octet = val.split( "." );
 				return parseInt(octet[0]) * 1000000000 + parseInt(octet[1]) * 1000000 + parseInt(octet[2]) * 1000 + parseInt(octet[3]);
-			default    : return val.toString().toLowerCase();
+			case "kmgt":
+				var v = val.toString().toLowerCase().match(/([0-9.,]+)\s*([kmgt])b/);
+				if(!v) return 0;
+				var z=v[2];
+				z = (z=='m') ? 3 : (z=='g') ? 6 : (z=='t') ? 9 : 0;
+				return v[1].toFloat()*Math.pow(10,z);
+			default: return val.toString().toLowerCase();
 		}
 	},
 
@@ -1603,17 +1407,18 @@
 		}
 	}
 }
+Wiki.addPageRender(Sortable);
 
 /** 240 table-filters 
  ** inspired by http://www.codeproject.com/jscript/filter.asp
  **/
 var TableFilter =
 {
-	onPageLoad: function(){
+	render: function(page,name){
 		this.All = "filter.all".localize();
 		this.FilterRow = 1; //row number of filter dropdowns
 		
-		$$('.table-filter table').each( function(table){
+		$ES('.table-filter table',page).each( function(table){
 			if( table.rows.length < 2 ) return;
 
 			/*
@@ -1676,8 +1481,9 @@
 			var v = $getText(r.cells[col]).clean().toLowerCase();
 			if(v == value) return;
 			value = v;
-			if(v.length > 32) v = v.substr(0,32)+ "...";
-			select.options[select.options.length] = new Option(v, value);
+			//if(v.length > 32) v = v.substr(0,32)+ "...";
+			//select.options[select.options.length] = new Option(v, value);
+			select.options[select.options.length] = new Option(v.trunc(32), value);
 		});
 		(select.options.length <= 2) ? select.hide() : select.show();
 		if(selectedValue != undefined) {
@@ -1718,16 +1524,17 @@
 		TableFilter.buildEmptyFilters(table); //fill remaining dropdowns
 	}
 }
+Wiki.addPageRender(TableFilter);
 
 
 /** 250 Categories: turn wikipage link into AJAXed popup **/
 var Categories =
 {
-	onPageLoad: function (){
-		this.jsp = Wiki.TemplateDir + '/AJAXCategories.jsp';
+	render: function (page,name){
 
-		$$('.category a.wikipage').each(function(link){
-			var page = Wiki.getPageName(link.href); if(!page) return;
+		$ES('.category a.wikipage',page).each(function(link){
+			var page = Wiki.getPageName(link.href); 
+			if(!page) return;
 			var wrap = new Element('span').injectBefore(link).adopt(link),
 				popup = new Element('div',{'class':'categoryPopup'}).inject(wrap),
 				popfx = popup.effect('opacity',{wait:false}).set(0);
@@ -1736,7 +1543,8 @@
 				.setProperties({ href:'#', title: "category.title".localize(page) })
 				.addEvent('click', function(e){
 				new Event(e).stop();  //dont jump to top of page ;-)
-				new Ajax( Categories.jsp, { 
+
+				new Ajax( Wiki.TemplateUrl + 'AJAXCategories.jsp', { 
 					postBody: '&page=' + page,
 					update: popup,
 					onComplete: function(){
@@ -1744,78 +1552,24 @@
 						wrap.addEvent('mouseover', function(e){ popfx.start(0.9); })
 							.addEvent('mouseout', function(e){ popfx.start(0); });
 						popup.setStyle('left', link.getPosition().x);
+						popup.setStyle('top', link.getPosition().y+16);
 						popfx.start(0.9); 
+						
+						$ES('li,div.categoryTitle',popup).each(function(el){
+							el.addEvent('mouseout',function(){ this.removeClass('hover')})
+							  .addEvent('mouseover',function(){ this.addClass('hover')});
+						});
+
+						
 					}
 				}).request();
 			});
 		});
 	} 
 }
-
-/**
- ** 260 Wiki Tips: 
- **/
-var WikiTips =
-{
-	onPageLoad: function() {    
-		var tips = [];
-		$$('*[class^=tip]').each( function(t){
-			var parms = t.className.split('-');
-			if( parms.length<=0 || parms[0] != 'tip' ) return;
-			t.className = "tip";
-
-			var body = new Element('span').injectWrapper(t).hide(),
-				caption = (parms[1]) ? parms[1].deCamelize(): "tip.default.title".localize();
-
-			tips.push( 
-				new Element('span',{
-					'class': 'tip-anchor',
-					'title': caption + '::' + body.innerHTML
-				}).setHTML(caption).inject(t)
-			);
-		});
-		if( tips.length>0 ) new Tips( tips , {'className':'tip'} );
-	}
-}
+Wiki.addPageRender(Categories);
 
 
-/**
- ** 270 Wiki Columns
- ** Dirk Frederickx, Mar 07
- **/
-var WikiColumns =
-{
-	onPageLoad: function() {    
-		var tips = [];
-		$$('*[class^=columns]').each( function(t){
-			var parms = t.className.split('-');
-			t.className='columns';
-			WikiColumns.buildColumns(t, parms[1] || 'auto');
-		});
-	},
-
-	buildColumns: function( el, width){
-		var breaks = $ES('hr',el);
-		if(!breaks || breaks.length==0) return;
-
-		var colCount = breaks.length+1;
-		width = (width=='auto') ? 98/colCount+'%' : width/colCount+'px';
-
-		var colDef = new Element('div',{'class':'col','styles':{'width':width}}),
-			col = colDef.clone().injectBefore(el.getFirst()),
-			n;
-		while(n = col.nextSibling){
-			if(n.tagName && n.tagName.toLowerCase() == 'hr'){
-				col = colDef.clone();
-				$(n).replaceWith(col);
-				continue;
-			}
-			col.appendChild(n);
-		}
-		new Element('div',{'styles':{'clear':'both'}}).inject(el);
-	}
-}
-
 /** 280 ZebraTable
  ** Color odd/even rows of table differently
  ** 1) odd rows get css class odd (ref. jspwiki.css )
@@ -1830,9 +1584,8 @@
  ** colors are specified in HEX (without #) format or html color names (red, lime, ...)
  **/
 var ZebraTable = {
-
-	onPageLoad: function(){
-		$$('*[class^=zebra]').each(function(z){
+	render: function(page,name){
+		$ES('*[class^=zebra]',page).each(function(z){
 			var parms = z.className.split('-'), 
 				isDefault = parms[1].test('table'),
 				c1 = '', 
@@ -1845,31 +1598,30 @@
 			},this);
 		},this);
 	},
-	zebrafy: function(isDefault, c1,c2){
+	zebrafy: function(isDefault, c1, c2){
 		var j=0;
 		$A($T(this).rows).each(function(r,i){
 			if(i==0 || (r.style.display=='none')) return;
-			if(isDefault) (j++ % 2 == 0) ? $(r).addClass('odd') : $(r).removeClass('odd');
-			else $(r).setStyle('background-color', (j++ % 2 == 0) ? c1 : c2 );
+			if(isDefault) (j++ % 2) ? $(r).addClass('odd') : $(r).removeClass('odd');
+			else $(r).setStyle('background-color', (j++ % 2) ? c1 : c2 );
 		});
 	}
 }
-
+Wiki.addPageRender(ZebraTable);
 
 /** Highlight Word
  ** Inspired by http://www.kryogenix.org/code/browser/searchhi/
  ** Modified 21006 to fix query string parsing and add case insensitivity
  ** Modified 20030227 by sgala@hisitech.com to skip words
  **                   with "-" and cut %2B (+) preceding pages
- ** Refactored for JSPWiki -- now based on regexp, by D.Frederickx. Nov 2005
+ ** Refactored for JSPWiki -- now based on regexp
  **/
 var HighlightWord =
 {
-	ReQuery: new RegExp( "(?:\\?|&)(?:q|query)=([^&]*)", "g" ),
-
 	onPageLoad: function (){
-		var q = Wiki.prefs.get('PrevQuery'); Wiki.prefs.set('PrevQuery', '');
-		if( !q && this.ReQuery.test(document.referrer)) q = RegExp.$1; 
+		var q = Wiki.prefs.get('PrevQuery');
+		Wiki.prefs.set('PrevQuery', '');
+		if( !q && document.referrer.test("(?:\\?|&)(?:q|query)=([^&]*)","g") ) q = RegExp.$1;
 		if( !q ) return;
 
 		var words = decodeURIComponent(q);
@@ -1883,18 +1635,19 @@
 	},
 
 	// recursive tree walk matching all text nodes
-	walkDomTree: function( node )
-	{
-		if( !node ) return; /* bugfix */
-		var nn = null;
-		for( var n = node.firstChild; n ; n = nn ) {
+	walkDomTree: function(node){
+		if( !node ) return;
+		for(var nn=null, n = node.firstChild; n ; n = nn) {
 			nn = n. nextSibling; /* prefetch nextSibling cause the tree will be modified */
-			this.walkDomTree( n );
+			this.walkDomTree(n);
 		}
 		// continue on text-nodes, not yet highlighted, with a word match
 		if( node.nodeType != 3 ) return;
 		if( node.parentNode.className == "searchword" ) return;
 		var s = node.innerText || node.textContent || '';
+
+		s = s.replace(/</g,'&lt;'); /* pre text elements may contain <xml> element */
+
 		if( !this.reMatch.test( s ) ) return;
 		var tmp = new Element('span').setHTML(s.replace(this.reMatch,"<span class='searchword'>$1</span>"));
 
@@ -1905,45 +1658,12 @@
 	}
 }
 
-
-/* 300 Javascript Code Prettifier
- * based on http://google-code-prettify.googlecode.com/svn/trunk/README.html
- */
-var WikiPrettify = {
-	onPageLoad: function(){
-		var els = $$('.prettify pre, .prettify code'); if(!els) return;
-
-		//TODO: load assets .css and .js
-		els.addClass('prettyprint');
-		prettyPrint();
-	}
-}
-
-
 window.addEvent('load', function(){
-
 	Wiki.onPageLoad();
-	WikiReflection.onPageLoad(); //before accordion cause impacts height!
-	WikiAccordion.onPageLoad();
-
-	TabbedSection.onPageLoad(); //after coordion or safari
-	QuickLinks.onPageLoad();
-	
-	//console.profile();
-	Collapsible.onPageLoad();
-	//console.profileEnd();
 
 	SearchBox.onPageLoad();
-	Sortable.onPageLoad();
-	TableFilter.onPageLoad();
-	RoundedCorners.onPageLoad();
-	ZebraTable.onPageLoad();
 	HighlightWord.onPageLoad();
-	GraphBar.onPageLoad();
-	Categories.onPageLoad();
-
-	WikiSlimbox.onPageLoad();
-	WikiTips.onPageLoad();
-	WikiColumns.onPageLoad();
-	WikiPrettify.onPageLoad();
+	Wiki.setFocus();
+	//console.profile();
+	//console.profileEnd();
 });
\ No newline at end of file

Added: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/scripts/jspwiki-commonstyles.js
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/scripts/jspwiki-commonstyles.js?rev=685201&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/scripts/jspwiki-commonstyles.js (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/scripts/jspwiki-commonstyles.js Tue Aug 12 08:47:28 2008
@@ -0,0 +1,470 @@
+/* 
+    JSPWiki - a JSP-based WikiWiki clone.
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.  
+ */
+
+/*
+ * jspwiki-commonstyles.js
+ * Contains additional Dynmic Styles 
+ *
+ *	114 Reflection (adds reflection to images): dynamic style 
+ *	132 Accordion object: dynamic style
+ *	220 RoundedCorners: dynamic style
+ *	260 WikiTips: dynamic style 
+ *	270 WikiColumns: dynamic style
+ *	300 Prettify: dynamic style
+ */
+ 
+ 
+/*
+Dynamic Style: Reflection  (114)
+
+Inspired by Reflection.js at http://cow.neondragon.net/stuff/reflection/
+Freely distributable under MIT-style license.
+Adapted for JSPWiki/BrushedTemplate, D.Frederickx, Sep 06
+
+Use:
+ 	%%reflection-height-opacity  [some-image.jpg] %%
+ */
+var WikiReflection = {
+
+	render: function(page,name){
+		$ES('*[class^=reflection]',page).each( function(w){
+			var parms = w.className.split('-');
+			$ES('img',w).each(function(img){
+				Reflection.add(img, parms[1], parms[2]);
+			}); 
+		});
+	}
+}
+Wiki.addPageRender(WikiReflection);
+
+/* FIXME : add delayed loading of reflection library */
+var Reflection = {
+
+	options: { height: 0.33, opacity: 0.5 },
+
+	add: function(img, height, opacity) {
+		//TODO Reflection.remove(image); --is this still needed?
+		height  = (height ) ? height/100 : this.options.height;
+		opacity = (opacity) ? opacity/100: this.options.opacity;
+
+		var div = new Element('div').injectAfter(img).adopt(img),
+			imgW = img.width,
+			imgH = img.height,
+			rH   = Math.floor(imgH * height); //reflection height
+
+		div.className = img.className.replace(/\breflection\b/, "");
+		div.style.cssText = img.backupStyle = img.style.cssText;
+		//div.setStyles({'width':img.width, 'height':imgH +rH, "maxWidth": imgW });
+		div.setStyles({'width':img.width, 'height':imgH +rH });
+		img.style.cssText = 'vertical-align: bottom';
+		//img.className = 'inline reflected';  //FIXME: is this still needed ??
+
+		if( window.ie ){ 
+			new Element('img', {'src': img.src, 'styles': {
+				'width': imgW,
+				'marginBottom': "-" + (imgH - rH) + 'px',
+				'filter': 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(opacity*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(height*100)+')'
+			}}).inject(div);
+		} else {
+			var r = new Element('canvas', {'width':imgW, 'height':rH, 'styles': {'width':imgW, 'height': rH}}).inject(div);
+			if( !r.getContext ) return;
+
+			var ctx = r.getContext("2d");
+			ctx.save();
+			ctx.translate(0, imgH-1);
+			ctx.scale(1, -1);
+			ctx.drawImage(img, 0, 0, imgW, imgH);
+			ctx.restore();
+			ctx.globalCompositeOperation = "destination-out";
+
+			var g = ctx.createLinearGradient(0, 0, 0, rH);
+			g.addColorStop( 0, "rgba(255, 255, 255, " + (1 - opacity) + ")" );
+			g.addColorStop( 1, "rgba(255, 255, 255, 1.0)" );
+			ctx.fillStyle = g;
+			ctx.rect( 0, 0, imgW, rH );
+			ctx.fill(); 
+		}
+	}
+}
+
+
+/** 132 Accordion for Tabs, Accordeons, CollapseBoxes
+ **
+ ** Following markup:
+ ** <div class="accordion">
+ **		<div class="tab-FirstTab">...<div>
+ **		<div class="tab-SecondTab">...<div>
+ ** </div>
+ **
+ **	is changed into
+ **	<div class="accordion">
+ **		<div class="toggle active">First Tab</div>
+ **		<div class="tab-FirstTab tab active">...</div>
+ **		<div class="toggle">Second Tab</div>
+ **		<div class="tab-SecondTab">...</div>
+ **	</div>
+ **/
+var WikiAccordion = {
+
+	render: function(page,name){
+
+		var toggle = new Element('div',{'class':'toggle'}),
+			bullet = new Element('div',{'class':'collapseBullet'});
+
+		$ES('.accordion, .tabbedAccordion, .leftAccordion, .rightAccordion',page).each( function(tt){
+			
+			var toggles=[], contents=[], togglemenu=false;
+			if(tt.hasClass('tabbedAccordion')){
+				togglemenu = new Element('div',{'class':'togglemenu'}).injectBefore(tt);
+			}
+			else if(tt.hasClass('leftAccordion')){
+				togglemenu = new Element('div',{'class':'sidemenu left'}).injectBefore(tt);
+			}
+			else if(tt.hasClass('rightAccordion')){
+				togglemenu = new Element('div',{'class':'sidemenu right'}).injectBefore(tt);
+			}
+			
+			tt.getChildren().each(function(tab) {
+				if( !tab.className.test('^tab-') ) return;
+
+				//FIXME use class to make tabs visible during printing 
+				//(i==0) ? tab.removeClass('hidetab'): tab.addClass('hidetab');
+
+				var title = tab.className.substr(4).deCamelize(),
+					t = toggle.clone().appendText(title);
+				if(togglemenu) {
+					toggles.push(t.inject(togglemenu));
+				} else {
+					toggles.push(t.adopt(bullet.clone()).injectBefore(tab));
+				}        
+				contents.push(tab.addClass('tab'));
+			});
+			
+			new Accordion(toggles, contents, {     
+				height: true,
+				alwaysHide: !togglemenu,
+				onComplete: function(){
+					var el = $(this.elements[this.previous]);
+					if (el.offsetHeight > 0) el.setStyle('height', 'auto');  
+				},
+				onActive: function(toggle,content){                          
+					toggle.addClass('active'); 
+					var b = toggle.getFirst();/*bullet*/
+					if(b) b.setProperties({'title':'collapse'.localize(), 'class':'collapseOpen'}).setHTML('-'); /* &raquo; */
+					content.addClass('active');//.removeClass('xhidetab'); 
+				},
+				onBackground: function(toggle,content){ 
+					content.setStyle('height', content['offsetHeight']);
+					toggle.removeClass('active'); 
+					var b = toggle.getFirst();/*bullet*/
+					if(b) b.setProperties({'title':'expand'.localize(), 'class':'collapseClose'}).setHTML('+'); /* &laquo; */
+					content.removeClass('active');//.addClass('xhidetab');
+				} 
+			});
+		});
+		bullet=toggle=null;
+	}
+}
+Wiki.addPageRender(WikiAccordion);
+
+
+/** 220 RoundedCorners --experimental
+ ** based on Nifty corners by Allesandro Fulciniti
+ ** www.pro.html.it
+ ** Refactored for JSPWiki
+ **
+ ** JSPWiki syntax:
+ **
+ **  %%roundedCorners-<corners>-<color>-<borderColor>
+ **  %%
+ **
+ **  roundedCorners-yyyy-ffc5ff-c0c0c0
+ **
+ **  corners: "yyyy" where first y: top-left,    2nd y: top-right,
+ **                           3rd y: bottom-left; 4th y: bottom-right
+ **     value can be: "y": Normal rounded corner (lowercase y)
+ **                    "s": Small rounded corner (lowercase s)
+ **                    "n": Normal square corner
+ **
+ **/
+var RoundedCorners =
+{
+	/** Definition of CORNER dimensions
+	 ** Normal    Normal+Border  Small  Small+Border   Big
+	 ** .....+++  .....BBB       ..+++  ..BBB          ........+++
+	 ** ...+++++  ...BB+++       .++++  .B+++          .....++++++
+	 ** ..++++++  ..B+++++       +++++  B++++          ...++++++++
+	 ** .+++++++  .B++++++                             ..+++++++++
+	 ** .+++++++  .B++++++                             .++++++++++
+	 ** ++++++++  B+++++++                             .++++++++++
+	 **                                                .++++++++++
+	 **                                                +++++++++++
+	 **
+	 ** legend: . background, B border, + forground color
+	 **/
+	$Top: {
+		'y' : /* normal */
+		 [ { margin: "5px", height: "1px", borderSide: "0", borderTop: "1px" }
+		 , { margin: "3px", height: "1px", borderSide: "2px" }
+		 , { margin: "2px", height: "1px", borderSide: "1px" }
+		 , { margin: "1px", height: "2px", borderSide: "1px" }
+		 ] ,
+		's' : /* small */
+		 [ { margin: "2px", height: "1px", borderSide: "0", borderTop: "1px" }
+		 , { margin: "1px", height: "1px", borderSide: "1px" }
+		 ] ,
+		'b' : /* big */ 
+		 [ { margin: "8px", height: "1px", borderSide: "0", borderTop: "1px" }
+		 , { margin: "6px", height: "1px", borderSide: "2px" }
+		 , { margin: "4px", height: "1px", borderSide: "1px" }
+		 , { margin: "3px", height: "1px", borderSide: "1px" }
+		 , { margin: "2px", height: "1px", borderSide: "1px" }
+		 , { margin: "1px", height: "3px", borderSide: "1px" }
+		 ] 
+	},
+
+	/**
+	 ** Usage:
+	 ** RoundedCorners.register( "#header", ['yyyy', '00f000', '32cd32'] );
+	 **/
+	$registry: {},
+	register: function(selector, parms){
+		this.$registry[selector] = parms;
+		return this;
+	},
+
+	render: function(page,name){
+		/* make reverse copies for bottom definitions */
+		this.$Bottom = {};
+		for(item in this.$Top){
+			this.$Bottom[item] = this.$Top[item].slice(0).reverse();
+		}
+
+		for(selector in this.$registry){  // CHECK NEEDED
+			var n = $$(selector), 
+				p = this.$registry[selector];
+			this.exec(n, p[0], p[1], p[2], p[3]);
+		}
+
+		$ES('*[class^=roundedCorners]',page).each(function(el){ 
+			var p = el.className.split('-');
+			if(p.length >= 2) this.exec([el], p[1], p[2], p[3], p[4] );
+		},this);
+	},
+
+	exec: function(nodes, corners, color, borderColor, background){
+		corners = (corners || "yyyy") + 'nnnn';
+		color = new Color(color) || 'transparent';
+		borderColor = new Color(borderColor);
+		background  = new Color(background);
+
+		var c = corners.split('');
+		/* c[0]=top-left; c[1]=top-right; c[2]=bottom-left; c[3]=bottom-right; */
+
+		nodes.each(function(n){
+			if( n.$passed ) return;
+						
+			var top = this.addCorner(this.$Top, c[0], c[1], color, borderColor, n),
+				bottom = this.addCorner(this.$Bottom, c[2], c[3], color, borderColor, n);
+
+			if(top || bottom) {
+				this.addBody(n, color, borderColor);
+
+				if(top){
+					var p = n.getStyle('padding-top').toInt();
+					top.setStyle('margin-top', p-top.getChildren().length);
+					n.setStyle('padding-top',0);
+					top.injectTop(n);
+				}
+
+				if(bottom){
+					var p = n.getStyle('padding-bottom').toInt();
+					bottom.setStyle('margin-bottom', p-bottom.getChildren().length);
+					n.setStyle('padding-bottom',0);
+					n.adopt(bottom);
+				}
+			}
+			if(borderColor) n.setStyle('border','none');
+			n.$passed=true;
+		},this);
+		top=bottom=null;
+	},
+
+	getTemplate: function(template, corners){
+		var t = false;
+		if(corners != 'nn') for(item in template){
+			if(corners.contains(item)){
+				t = template[item];
+				break;
+			}
+		}
+		return t;
+	},
+
+	addCorner: function(corner, left, right, color, border, n){
+
+		corner = this.getTemplate(corner, left+right);
+		if(!corner) return false;
+
+		var padl = n.getStyle('padding-left').toInt(), 
+			padr = n.getStyle('padding-right').toInt();
+		var node = new Element('b',{'class':'roundedCorners','styles':{
+			'display':'block',
+			'margin-left':-1*padl,
+			'margin-right':-1*padr
+		} });
+
+		corner.each(function(line){
+			var el = new Element('div', {'styles': {
+				'height':line.height,
+				'overflow':'hidden',
+				'border-width':'0',
+				'background-color':color.hex
+			} });
+
+			if(border.hex){
+				el.setStyles({'border-color':border.hex,'border-style':'solid'});
+				
+				if(line.borderTop){ 
+					el.setStyles({'border-top-width':line.borderTop,'height':'0'});				
+				}
+			}
+			if(left != 'n') el.setStyle('margin-left', line.margin);
+			if(right != 'n') el.setStyle('margin-right', line.margin);
+
+			if(border.hex){
+				el.setStyles({
+					'border-left-width': (left  == 'n') ? '1px': line.borderSide,
+					'border-right-width': (right == 'n') ? '1px': line.borderSide
+				});
+			}
+			node.adopt(el);
+		});
+		return node;
+	},
+
+	// move all children of the node inside a DIV and set color and bordercolor
+	addBody: function(n, color, border){
+
+		var padl = n.getStyle('padding-left').toInt(),
+			padr = n.getStyle('padding-right').toInt();	
+			
+		var container = new Element('div',{'styles':{
+			'overflow':'hidden',
+			'margin-left':-1*padl,
+			'margin-right':-1*padr,
+			'padding-left':(padl==0) ? 4 : padl,
+			'padding-right':(padr==0) ? 4 : padr,
+			'background-color':color.hex
+		} }).wrapChildren(n);
+
+		if(border.hex){
+			//n.setStyles('border','');
+			var st = "1px solid " + border.hex
+			container.setStyles({'border-left':st, 'border-right': st });
+		}
+	}
+}
+Wiki.addPageRender(RoundedCorners);
+
+
+/**
+ ** 260 Wiki Tips: 
+ **/
+var WikiTips =
+{
+	render: function(page,name) {    
+		var tips = [];
+		$ES('*[class^=tip]',page).each( function(t){
+			var parms = t.className.split('-');
+			if( parms.length<=0 || parms[0] != 'tip' ) return;
+			t.className = "tip";
+
+			var body = new Element('span').wrapChildren(t).hide(),
+				caption = (parms[1]) ? parms[1].deCamelize(): "tip.default.title".localize();
+
+			tips.push( 
+				new Element('span',{
+					'class': 'tip-anchor',
+					'title': caption + '::' + body.innerHTML
+				}).setHTML(caption).inject(t)
+			);
+		});
+		if( tips.length>0 ) new Tips( tips , {'className':'tip', 'Xfixed':true} );
+	}
+}
+Wiki.addPageRender(WikiTips);
+
+
+/**
+ ** 270 Wiki Columns
+ ** Dirk Frederickx, Mar 07
+ **/
+var WikiColumns =
+{
+	render: function(page,name) {    
+		var tips = [];
+		$ES('*[class^=columns]',page).each( function(t){
+			var parms = t.className.split('-');
+			t.className='columns';
+			WikiColumns.buildColumns(t, parms[1] || 'auto');
+		});
+	},
+
+	buildColumns: function( el, width){
+		var breaks = $ES('hr',el);
+		if(!breaks || breaks.length==0) return;
+
+		var colCount = breaks.length+1;
+		width = (width=='auto') ? 98/colCount+'%' : width/colCount+'px';
+
+		var colDef = new Element('div',{'class':'col','styles':{'width':width}}),
+			col = colDef.clone().injectBefore(el.getFirst()),
+			n;
+		while(n = col.nextSibling){
+			if(n.tagName && n.tagName.toLowerCase() == 'hr'){
+				col = colDef.clone();
+				$(n).replaceWith(col);
+				continue;
+			}
+			col.appendChild(n);
+		}
+		new Element('div',{'styles':{'clear':'both'}}).inject(el);
+	}
+}
+Wiki.addPageRender(WikiColumns);
+
+
+/* 300 Javascript Code Prettifier
+ * based on http://google-code-prettify.googlecode.com/svn/trunk/README.html
+ */
+var WikiPrettify = {
+	render: function(page,name){
+		var els = $ES('.prettify pre, .prettify code',page); 
+		if(!els || els.length==0) return;
+		els.addClass('prettyprint');		
+
+		//TODO: load assets .css and .js 
+		//PRETTIFY: patch added to avoid processing of the same element
+		prettyPrint(page);
+	}
+}
+Wiki.addPageRender(WikiPrettify);



Mime
View raw message