You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by is...@apache.org on 2013/11/03 22:36:27 UTC

svn commit: r1538467 [14/20] - in /mahout/site/mahout_cms: ./ cgi-bin/ content/ content/css/ content/developers/ content/general/ content/images/ content/js/ content/users/ content/users/basics/ content/users/classification/ content/users/clustering/ c...

Added: mahout/site/mahout_cms/content/js/search.js
URL: http://svn.apache.org/viewvc/mahout/site/mahout_cms/content/js/search.js?rev=1538467&view=auto
==============================================================================
--- mahout/site/mahout_cms/content/js/search.js (added)
+++ mahout/site/mahout_cms/content/js/search.js Sun Nov  3 21:36:23 2013
@@ -0,0 +1,21 @@
+function initSearch(){
+    var methods = {
+        defaultValueActsAsHint: function(element){
+            element = $(element);
+            element._default = element.value;
+            return element.observe('focus', function(){
+                if(element._default != element.value) return;
+                element.removeClassName('hint').value = '';
+            }).observe('blur', function(){
+                if(element.value.strip() != '') return;
+                element.addClassName('hint').value = element._default;
+            }).addClassName('hint');
+        }
+    };
+    $w('input textarea').each(function(tag){ Element.addMethods(tag, methods) });
+}
+initSearch();
+
+document.observe('dom:loaded', function(){
+    $('searchDocs').defaultValueActsAsHint();
+});
\ No newline at end of file

Added: mahout/site/mahout_cms/content/js/slides.js
URL: http://svn.apache.org/viewvc/mahout/site/mahout_cms/content/js/slides.js?rev=1538467&view=auto
==============================================================================
--- mahout/site/mahout_cms/content/js/slides.js (added)
+++ mahout/site/mahout_cms/content/js/slides.js Sun Nov  3 21:36:23 2013
@@ -0,0 +1,109 @@
+var Slides = Class.create({
+
+	initialize: function(element, options) {		
+		this.options = {
+      		Duration: 1,
+			Delay: 10.0,
+			Random: true,
+			Slideshow:true,
+			Controls:true
+    	}
+		Object.extend(this.options, options || {});
+
+    	this.element        = $(element);
+		this.slides			= this.element.childElements();
+		this.num_slides		= this.slides.length;		
+		this.current_slide 	= (this.options.Random) ? (Math.floor(Math.random()*this.num_slides)) : 0;
+		this.end_slide		= this.num_slides - 1;
+		
+		this.slides.invoke('hide');
+		this.slides[this.current_slide].show();
+				
+		if (this.options.Slideshow) { 
+			this.startSlideshow();
+		}				
+		if (this.options.Controls) {
+			this.addControls();
+		}		
+	},
+	
+	addControls: function() {
+		this.btn_previous	= $('previous');
+		this.btn_next 		= $('next');
+		this.btn_start		= $('start');
+		this.btn_stop		= $('stop');
+		
+		this.btn_previous.observe('click', this.moveToPrevious.bindAsEventListener(this));
+		this.btn_next.observe('click', this.moveToNext.bindAsEventListener(this));
+		this.btn_start.observe('click', this.startSlideshow.bindAsEventListener(this));
+		this.btn_stop.observe('click', this.stopSlideshow.bindAsEventListener(this));
+	},
+
+	startSlideshow: function(event) {
+		if (event) { Event.stop(event); }
+		if (!this.running)	{
+			this.fadeStartBtn();
+			this.executer = new PeriodicalExecuter(function(){
+	  			this.updateSlide(this.current_slide+1);
+	 		}.bind(this),this.options.Delay);
+			this.running=true;
+		}
+		
+	},
+	
+	fadeStartBtn: function() {
+		var startBtn = $('start');
+		var stopBtn = $('stop');
+		Effect.Fade(startBtn, { duration: 0.3 }),
+		Effect.Appear(stopBtn, { duration: 0.3 }) 
+	},
+	
+	stopSlideshow: function(event) {	
+		if (event) { Event.stop(event); } 
+		if (this.executer) {
+			this.fadeStopBtn();
+			this.executer.stop();
+			this.running=false;
+		}	 
+	},
+	
+	fadeStopBtn: function() {
+		var startBtn = $('start');
+		var stopBtn = $('stop');
+		Effect.Fade(stopBtn, { duration: 0.3 }),
+		Effect.Appear(startBtn, { duration: 0.3 }) 
+	},
+
+	moveToPrevious: function (event) {
+		if (event) { Event.stop(event); }
+		//this.stopSlideshow();
+  		this.updateSlide(this.current_slide-1);
+	},
+
+	moveToNext: function (event) {
+		if (event) { Event.stop(event); }
+		//this.stopSlideshow();
+  		this.updateSlide(this.current_slide+1);
+	},
+	
+	updateSlide: function(next_slide) {
+		if (next_slide > this.end_slide) { 
+				next_slide = 0; 
+		} 
+		else if ( next_slide == -1 ) {
+				next_slide = this.end_slide;
+		}
+		
+		this.fadeInOut(next_slide, this.current_slide);		
+	},
+
+ 	fadeInOut: function (next, current) {		
+		new Effect.Parallel([
+			new Effect.Fade(this.slides[current], { sync: true }),
+			new Effect.Appear(this.slides[next], { sync: true }) 
+  		], { duration: this.options.Duration });
+		
+		this.current_slide = next;		
+	}
+
+});
\ No newline at end of file