W3C home > Mailing lists > Public > www-validator-cvs@w3.org > September 2009

2006/unicorn/WebContent/scripts w3c_unicorn_results.js,1.3,1.4

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Mon, 14 Sep 2009 07:13:55 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1Mn5l5-0000Qi-Ub@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/WebContent/scripts
In directory hutz:/tmp/cvs-serv1638/WebContent/scripts

Modified Files:
	w3c_unicorn_results.js 
Log Message:
new script

Index: w3c_unicorn_results.js
===================================================================
RCS file: /sources/public/2006/unicorn/WebContent/scripts/w3c_unicorn_results.js,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- w3c_unicorn_results.js	28 Aug 2009 17:07:03 -0000	1.3
+++ w3c_unicorn_results.js	14 Sep 2009 07:13:53 -0000	1.4
@@ -2,38 +2,175 @@
 	
 	start: function() {
 		
-		W3C.Links = $$('h2').concat($$('h3'));
-		W3C.Links.each(function(link) {
-			link.addClass('pointer');
-			link.addClass('toggles');
+		W3C.ObserverEvents = true;
+		W3C.Observers = $$('.observer');
+		
+		var slideDuration = 500;
+		var invalidObservers = $$('.observer.invalid');
+		var scroller = new Fx.Scroll(document);
+		
+		$$('.title').each(function(title) {
+			title.addClass('pointer');
+			title.addClass('toggles');
 		});
 		
-		$$('div.warnings').getElement('div.result').slide('hide');
-		if ($$('div.observer.invalid').length > 0)	
-			$$('div.observer.valid').getElement('div.results').slide('hide');
-		else
-			$$('div.observer.valid').getElement('h2').addClass('toggled');
+		$$('.section').each(function(section) {
+			var title = section.getElement('.title');
+			var block = section.getElement('.block');
+			section.store('fxSlide', new Fx.Slide(block, {'duration': slideDuration, 'link': 'cancel'}));
+			section.store('block', block);
+			title.addEvent('click', function(event) {
+				if (!section.hasClass('observer') || W3C.ObserverEvents)
+					W3C.toggle(section);
+			});
+		});
 		
-		$$('div.observer.invalid').getElement('h2').addClass('toggled');
-		$$('div.errors').getElement('h3').addClass('toggled');
-		$$('div.infos').getElement('h3').addClass('toggled');
+		$$('.observer .section').each(function(section) {
+			if (section.hasClass('warnings'))
+				W3C.close(section, false).callChain();
+			if (section.hasClass('errors') || section.hasClass('infos'))
+				W3C.open(section, false).callChain();
+		});
 		
-		$$('div.observer').each(function(observer) {
-			observer.getElement('h2').addEvent('click', function(event) {
-				observer.getElement('div.results').slide('toggle');
-				this.toggleClass('toggled');
+		$$('.observer .title a').each(function(a) {
+			a.addEvent('click', function (event) {
+				event.stopPropagation();
 			});
 		});
 		
-		W3C.ResultBlock = $$('div.errors').concat($$('div.infos'), $$('div.warnings')); 
-		W3C.ResultBlock.each(function(results) {
-			results.getElement('h3').addEvent('click', function(event){
-				results.getElement('div.result').slide('toggle');
-				results.getParent('div').getParent('div').setStyle('height', 'auto');
-				this.toggleClass('toggled');
+		$$('.observer').each(function(observer) {
+			W3C.open(observer, false).callChain();
+			if (observer.hasClass('valid') && invalidObservers.length > 0) 
+				W3C.close(observer, false).callChain();
+			observer.getElement('a.anchor').addEvent('click', function(event) {
+				event.preventDefault();
+				W3C.open(observer, true);
+				scroller.toElement(observer);
+				
+				/*if (!observer.retrieve('open')) {
+					W3C.closeAllObserversBut(observer, true).chain(function() {
+						scroller.toElement(observer);
+					});
+				} else {
+					scroller.toElement(observer);
+				}*/
 			});
 		});
 		
+		var mySmoothScroll = new Fx.SmoothScroll({
+		    links: '.smooth',
+		    wheelStops: true
+		});
+	},
+	
+	toggle: function(section) {
+		if (!section.hasClass('observer'))
+			W3C.observersEvents(false);
+		var title = section.getElement('.title');
+		var slide = section.retrieve('fxSlide');
+	    if (section.retrieve('open')) {
+	    	/*title.removeClass('toggled');
+	    	section.store('open', false);
+	    	return slide.slideOut().chain(function(){
+			    section.getElement('div').setStyle('height', '0');
+			    slide.callChain();
+			}).chain(function() {
+				W3C.observersEvents(true);
+				slide.callChain();
+			});*/
+	    	return W3C.close(section, true);
+	    } else {
+	    	/*title.addClass('toggled');
+	    	section.store('open', true);
+	    	return slide.slideIn().chain(function(){
+			    section.getElement('div').setStyle('height', 'auto');
+			    slide.callChain();
+			}).chain(function() {
+				W3C.observersEvents(true);
+				slide.callChain();
+			});*/
+	    	return W3C.open(section, true);
+	    }
+		/*return slide.toggle().chain(function(){
+		    if (section.retrieve('open'))
+		    	section.getElement('div').setStyle('height', 'auto');
+		    else
+		    	section.getElement('div').setStyle('height', '0');
+		    slide.callChain();
+		}).chain(function() {
+			W3C.observersEvents(true);
+			slide.callChain();
+		});*/
+	},
+	
+	close: function(section, withFx) {
+		var opened = section.retrieve('open');
+		var title = section.getElement('.title');
+		var slide = section.retrieve('fxSlide');
+	    title.removeClass('toggled');
+	    section.store('open', false);
+		if (withFx && opened) {
+			return slide.slideOut().chain(function(){
+		    	section.getElement('div').setStyle('height', '0');
+		    	slide.callChain();
+			});
+		} else {
+			return slide.hide().chain(function(){
+				section.getElement('div').setStyle('height', '0');
+				slide.callChain();
+			});
+		}
+	},
+	
+	open: function(section, withFx) {
+		var closed = !section.retrieve('open');
+		var title = section.getElement('.title');
+		var slide = section.retrieve('fxSlide');
+	    title.addClass('toggled');
+	    section.store('open', true);
+	    if (withFx && closed) {
+	    	return slide.slideIn().chain(function(){
+		    	section.getElement('div').setStyle('height', 'auto');
+		    	slide.callChain();
+			});
+		} else {
+	    	return slide.show().chain(function(){
+	    		section.getElement('div').setStyle('height', 'auto');
+	    		slide.callChain();
+	    	});
+	    }
+	},
+	
+	closeAllObserversBut: function(observer, withFx) {
+		W3C.Observers.each(function (ob) {
+			if (ob != observer)
+				W3C.close(ob, withFx).callChain();
+		});
+		return W3C.open(observer, withFx);
+	},
+	
+	
+	closeAllSectionsBut: function(observer, section, withFx) {
+		return;
+	},
+	
+	observersEvents: function(on) {
+		if (on) {
+			W3C.ObserverEvents = true;
+			W3C.Observers.getElement('.title').addClass('pointer');
+		} else {
+			W3C.ObserverEvents = true;
+			W3C.Observers.getElement('.title').removeClass('pointer');
+		}
+	},
+	
+	setHash: function(hash){
+		if (window.webkit419){
+			W3C.FakeForm = W3C.FakeForm || new Element('form', {'method': 'get'}).injectInside(document.body);
+			W3C.FakeForm.setProperty('action', '#' + hash).submit();
+		} else {
+			window.location.hash = hash;
+		}
 	}
 };
 
Received on Monday, 14 September 2009 07:14:04 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:14 GMT