Commits

Shu Zong Chen  committed 03cd8f7

Made pause_on_nav option for nav buttons

  • Participants
  • Parent commits a978efb

Comments (0)

Files changed (1)

File js/eldridge_park.js

 eldridge_park = function(){};
 
+eldridge_park.mixin = function(){
+	var ret = {};
+	dojo.forEach(arguments, function(item, i){
+		ret = dojo.mixin(ret, item);
+	});
+	console.log(ret);
+	return ret;
+}
+
 dojo.declare("eldridge_park.nav", null, {
 	nav_class: "ep_nav",
 	navitem_class: "ep_navitem",
 	nav_style: {},
 	item_style: {},
-	hover_style: {},
+	item_active_style: {},
+	item_hover_style: {},
+	nav_base_style: {},
+	item_base_style: {},
+	item_active_base_style: {},
+	item_hover_base_style: {},
+	pause_on_nav: false,
 	constructor: function(opts){
 		if (typeof opts == 'undefined'){
 			opts = {};
 		}
-		dojo.safeMixin(this, opts);
+		dojo.mixin(this, opts);
+		this.nav_style = eldridge_park.mixin(this.nav_base_style, this.nav_style);
+		this.item_style = eldridge_park.mixin(this.item_base_style, this.item_style);
+		this.item_active_style = eldridge_park.mixin(this.item_active_base_style, this.item_active_style);
+		this.item_hover_style = eldridge_park.mixin(this.item_hover_base_style, this.item_hover_style);
 		this._items = [];
 		this.addNav();
 		this.len = 0;
 	onClick: function(idx){
 		this.jumpTo(idx);
 		this.carousel.fadeTo(idx);
+		if (this.pause_on_nav){
+			this.carousel.stop();
+		}
 	},
 	onActive: function(element){
 		dojo.style(element, this.item_active_style);
 });
 
 dojo.declare("eldridge_park.block_nav", eldridge_park.nav, {
-	nav_style: {
+	nav_base_style: {
 		'position': 'absolute',
 		'left': '10px',
 		'bottom': '10px',
 		'height':'30px',
 		'zIndex':100
 	},
-	item_style: {
+	item_base_style: {
 		'float': 'left',
 		'border': '1px solid #666',
 		'height': '30px',
 		'marginRight': '5px',
 		'cursor': 'pointer'
 	},
-	item_hover_style: {
+	item_hover_base_style: {
 		'backgroundColor':'#666'
 	},
-	item_active_style: {
+	item_active_base_style: {
 		'backgroundColor':'#999'
 	},
 	constructor: function(opts){
 });
 
 dojo.declare("eldridge_park.char_nav", eldridge_park.nav, {
-	nav_style: {
+	nav_base_style: {
 		'position': 'absolute',
 		'left': '10px',
 		'bottom': '0px',
 		'height':'30px',
 		'zIndex':100
 	},
-	item_style: {
+	item_base_style: {
 		'float': 'left',
 		'color': '#666',
 		'fontSize': '30px',
 		'marginRight': '5px',
 		'cursor': 'pointer'
 	},
-	item_hover_style: {
+	item_hover_base_style: {
 		'color':'#999'
 	},
-	item_active_style: {
+	item_active_base_style: {
 		'color':'#aaa'
 	},
 	item_text: "<p>&bull;</p>",
 	setClear: function(e){
 		dojo.style(e, "opacity", "0.0");
 	},
+	fadeOut: function(e, dur){
+		dojo.fadeOut({
+			node: e,
+			duration: dur,
+		}).play();
+	},
 	jumpTo: function(n){
 		var items = this.items();
 		var top_item = items.splice(n, 1);
 		this.raise(top_item[0]);
 		dojo.forEach(items, function(e){
 			this.lower(e);
+			this.fadeOut(e, dur);
 		}, this);
 		dojo.fadeIn({
 			node: top_item[0],
 			onEnd: dojo.hitch(this, "setTimer", i)
 		}).play();
 	},
+	stop: function(){
+		this.clearTimer();
+	},
 	clearTimer: function(){
 		if (this.timeout != null){
 			clearTimeout(this.timeout);