scripts/components/calendarContext.js
function reducer(context, action, target, state) {
	const newState = Object.assign({}, state);
	let actor;
	
	switch(action.type) {
		case INIT_CONTEXT_ACTION_TYPE:
			newState.days = context.reduce((acc, actor, name) => {
				if(name.indexOf("_weekDay") > 0)
					acc.push(name);
				return acc;
			}, []);

			return newState;
		case "resetDays":
			context.map(resetDays);
			
			return newState;
		case "deselectDays":
			context.map(deselectDays);
			
			return newState;
		case "daySelected":
			const selected = context.find(newState.selectedDay);
			
			if(selected){
				removeSelection(context, newState);
			}

			actor = context.find(target, {pushClassNames: raiseTargetNotfound(target)});
			actor.pushClassNames(".calendar.day_label-selected");
			newState.selectedDay = target;
			
			return newState;
		case "clearSelectedDay":
			removeSelection(context, newState);
			return newState;
		case "changeMonth":
			removeSelection(context, newState);
			return newState;
		case "changeCalendar":
		  context.map(function(actor){
		    if(!actor || actor.name === undefined)
		    	raiseTargetNotfound(target);

		    const className = actor.getInitialClassName();
		    
		    actor.resetClassNames([className,
		    	className+"-lang_"+action.lang, 
		    	"#"+actor.name, 
		    	"#"+actor.name+"-lang_"+action.lang,
		    	"#"+actor.name+"-os_"+System.OS
	    	]);
		    // actor.pushClassName("#"+actor.name+"-os_"+System.OS);
		  });
		  
		  return newState;
		case "updateDayType":
			actor = context.find(target);
			const data = action.data;
			
			if(data.isWeekend) {
				actor.pushClassNames(".calendar.day_label-weekend");
			}

			if(Array.isArray(data.specialDay) && data.specialDay.length > 0) {
				actor.pushClassNames(".calendar.day_label-specialDay");
			}

			if(data.month != "current") {
				actor.pushClassNames(".calendar.day_label-deactiveDays");
			}
			
			return newState;
	}

	return state;
}
function reducer(context, action, target, state) {
	const newState = Object.assign({}, state);
	let actor;
	
	switch(action.type) {
		case INIT_CONTEXT_ACTION_TYPE:
			newState.days = context.reduce((acc, actor, name) => {
				if(name.indexOf("_weekDay") > 0)
					acc.push(name);
				return acc;
			}, []);

			return newState;
		case "resetDays":
			context.map(resetDays);
			
			return newState;
		case "deselectDays":
			context.map(deselectDays);
			
			return newState;
		case "daySelected":
			const selected = context.find(newState.selectedDay);
			
			if(selected){
				removeSelection(context, newState);
			}

			actor = context.find(target, {pushClassNames: raiseTargetNotfound(target)});
			actor.pushClassNames(".calendar.day_label-selected");
			newState.selectedDay = target;
			
			return newState;
		case "clearSelectedDay":
			removeSelection(context, newState);
			return newState;
		case "changeMonth":
			removeSelection(context, newState);
			return newState;
		case "changeCalendar":
		  context.map(function(actor){
		    if(!actor || actor.name === undefined)
		    	raiseTargetNotfound(target);

		    const className = actor.getInitialClassName();
		    
		    actor.resetClassNames([className,
		    	className+"-lang_"+action.lang, 
		    	"#"+actor.name, 
		    	"#"+actor.name+"-lang_"+action.lang,
		    	"#"+actor.name+"-os_"+System.OS
	    	]);
		    // actor.pushClassName("#"+actor.name+"-os_"+System.OS);
		  });
		  
		  return newState;
		case "updateDayType":
			actor = context.find(target);
			const data = action.data;
			
			if(data.isWeekend) {
				actor.pushClassNames(".calendar.day_label-weekend");
			}

			if(Array.isArray(data.specialDay) && data.specialDay.length > 0) {
				actor.pushClassNames(".calendar.day_label-specialDay");
			}

			if(data.month != "current") {
				actor.pushClassNames(".calendar.day_label-deactiveDays");
			}
			
			return newState;
	}

	return state;
}
function reducer ( context , action , target , state ) { const newState = Object . assign ( { } , state ) ; let actor ; switch ( action . type ) { case INIT_CONTEXT_ACTION_TYPE : newState . days = context . reduce ( ( acc , actor , name ) => { if ( name . indexOf ( "_weekDay" ) > 0 ) acc . push ( name ) ; return acc ; } , [ ] ) ; return newState ; case "resetDays" : context . map ( resetDays ) ; return newState ; case "deselectDays" : context . map ( deselectDays ) ; return newState ; case "daySelected" : const selected = context . find ( newState . selectedDay ) ; if ( selected ) { removeSelection ( context , newState ) ; } actor = context . find ( target , { pushClassNames : raiseTargetNotfound ( target ) } ) ; actor . pushClassNames ( ".calendar.day_label-selected" ) ; newState . selectedDay = target ; return newState ; case "clearSelectedDay" : removeSelection ( context , newState ) ; return newState ; case "changeMonth" : removeSelection ( context , newState ) ; return newState ; case "changeCalendar" : context . map ( function ( actor ) { if ( ! actor || actor . name === undefined ) raiseTargetNotfound ( target ) ; const className = actor . getInitialClassName ( ) ; actor . resetClassNames ( [ className , className + "-lang_" + action . lang , "#" + actor . name , "#" + actor . name + "-lang_" + action . lang , "#" + actor . name + "-os_" + System . OS ] ) ; // actor.pushClassName("#"+actor.name+"-os_"+System.OS); } ) ; return newState ; case "updateDayType" : actor = context . find ( target ) ; const data = action . data ; if ( data . isWeekend ) { actor . pushClassNames ( ".calendar.day_label-weekend" ) ; } if ( Array . isArray ( data . specialDay ) && data . specialDay . length > 0 ) { actor . pushClassNames ( ".calendar.day_label-specialDay" ) ; } if ( data . month != "current" ) { actor . pushClassNames ( ".calendar.day_label-deactiveDays" ) ; } return newState ; } return state ; }
reducer for context's components
reducer for context s components