<commit_before>window.onload = function(){
	var newScroll = new handyScroller({
			box:document.getElementById("panelContent"),
			side: "xy",
			stretch:[true,false],
			divideCorner:true,
			wheelX:30,
			scrollStep:[1,1]
	});
};

function handyScroller(o){
	this.stretch = o.stretch;
	this.buttonClick = null;
	this.divideCorner = o.divideCorner;
	this.side = o.side;
	this.xy = null;
	this.scrollStep = o.scrollStep;
	this.wheelX = o.wheelX;
	this.stylesXY = [["top","height","right","Y","width"],["left","width","bottom","X","height"]];
	this.mainBox = o.box;
	this.contentBox = null;
	this.wheelBox = null;
	this.elements = [[null,  //0: Area		this.elementsY[0]
					  null,  //1: Padding	this.elementsY[1]
					  null], //2: Button	this.elementsY[2]
					 [null,  //0: Area		this.elementsX[0]
					  null,  //1: Padding	this.elementsX[1]
					  null]]; //2: Button	this.elementsX[2]

	this.props = [[null,	 //0: boxTop			this.propsY[0]
				    null,	 //1: contentTop		this.propsY[1]
				    null,	 //2: areaTop			this.propsY[2]
				    null,	 //3: paddingTop		this.propsY[3]
				    null,	 //4: buttonTop			this.propsY[4]
				    null,	 //5: boxHeight			this.propsY[5]
				    null,	 //6: contentHeight		this.propsY[6]
				    null,	 //7: areaHeight		this.propsY[7]
				    null,	 //8: paddingHeight		this.propsY[8]
				    null],	 //9: buttonHeight		this.propsY[9]
				   [null,	 //0: boxLeft			this.propsX[0]
				    null,	 //1: contentLeft		this.propsX[1]
				    null,	 //2: areaLeft			this.propsX[2]
				    null,	 //3: paddingLeft		this.propsX[3]
				    null,	 //4: buttonLeft		this.propsX[4]
				    null,	 //5: boxWidth			this.propsX[5]
				    null,	 //6: contentWidth		this.propsX[6]
				    null,	 //7: areaWidth			this.propsX[7]
				    null,	 //8: paddingWidth		this.propsX[8]
				    null]];	 //9: buttonWidth		this.propsX[9]
	this.scrollThick = [null,null];
	var x = this.side==="y"||this.side==="xy"||this.side==="yx"? 0:1;
	var y = this.side==="x"||this.side==="xy"||this.side==="yx" ? 2:1;

	createBoxes.call(this);
	createWheelEvent.call(this);
	for(;x<y;x++){
		this.xy = x;
		createScrolls.call(this);
		this.refreshMe();
		this.stretchButton();
		this.setPaddings();
	}
	createWheelBox.call(this);
}

function createBoxes(){
	var innerObj = this.mainBox.children;
	var isStatic = window.getComputedStyle(this.mainBox,null).getPropertyValue("position")!=="static"? "":"position:relative;";

	this.mainBox.style = "overflow:hidden;"+isStatic;

	this.contentBox = document.createElement("DIV");
	this.contentBox.setAttribute("class","handyBox");
	this.contentBox.style = "position:relative";
	for(;innerObj.length!==0;){
		this.contentBox.appendChild(innerObj[0]);
	}
	this.mainBox.appendChild(this.contentBox);
}

function createScrolls(){
	this.elements[this.xy][0] = document.createElement("DIV");
	this.elements[this.xy][1] = document.createElement("DIV");
	this.elements[this.xy][2] = document.createElement("DIV");

	this.elements[this.xy][0].setAttribute("class","handyScrollBox"+this.stylesXY[this.xy][3]);
	this.elements[this.xy][1].setAttribute("class","handyScrollArea"+this.stylesXY[this.xy][3]);
	this.elements[this.xy][2].setAttribute("class","handyScroller"+this.stylesXY[this.xy][3]);
	this.elements[this.xy][0].style = "position:absolute;"+this.stylesXY[this.xy][0]+":0px;"+this.stylesXY[this.xy][2]+":0px;"+this.stylesXY[this.xy][1]+":100%;box-sizing:border-box";
	this.elements[this.xy][1].style= "position:relative;cursor:pointer;top:0px;left:0px;width:100%;height:100%;box-sizing:border-box;border:0;padding:0;margin:0";
	this.elements[this.xy][2].style = "position:relative";

	this.elements[this.xy][1].appendChild(this.elements[this.xy][2]);
	this.elements[this.xy][0].appendChild(this.elements[this.xy][1]);
	this.mainBox.appendChild(this.elements[this.xy][0]);

	var clickMe = clickMe.bind(this,this.elements[this.xy][1]);
	var releaseMe = releaseMe.bind(this);
	var scrollMove = this.scrollMove.bind(this);

	this.elements[this.xy][1].addEventListener("mousedown",clickMe);

	function clickMe(obj){
		var checkClass = obj.parentNode.getAttribute("class");
		this.xy = checkClass.charAt(checkClass.length-1)==="Y" ? 0:1;
		this.refreshMe();
		this.prepareToMove();
		this.scrollMove();
		this.refreshMe();
		this.prepareToMove();
		document.body.addEventListener("mouseup",releaseMe);
		document.body.addEventListener("mousemove",scrollMove);
		document.body.style.cursor = "pointer";
	}

	function releaseMe(){
		document.body.removeEventListener("mouseup",releaseMe);
		document.body.removeEventListener("mousemove",scrollMove);
		document.body.style.cursor = "default";
	}
}

function createWheelBox(){
	if((!this.isContentFit(1))&&(this.side!=="y")){
		this.wheelBox = document.createElement("DIV");
		this.wheelBox.setAttribute("class","handyWheelBox");
		this.wheelBox.style = "position:absolute;right:0px;width:"+this.wheelX+"%;";
		this.mainBox.insertBefore(this.wheelBox,this.elements[0][0]);
	}
}

function createWheelEvent(){
	var wheelMe = wheelScroll.bind(this);
	this.mainBox.addEventListener("wheel", wheelMe);
	this.mainBox.addEventListener("mouseover", mouseOverMe);
	this.mainBox.addEventListener("mouseout", mouseOutMe);

	function mouseOverMe(){
		window.onwheel=function(){return false;};
		window.onmousewheel=function(){return false;};
	}

	function mouseOutMe(){
		window.onwheel=null;
		window.onmousewheel=null;
	}

	function wheelScroll(){
		this.xy = 1;
		var side = ((this.getMouse()/this.props[1][5])*100)<(100-this.wheelX) ? 0:1;
		this.xy = side;

		if(this.isContentFit(this.xy)){
			return;
		}

		var e = window.event || e;
		var wheel = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
		var move = this.xy===0 ? ((window.innerHeight/100)*this.scrollStep[this.xy]):((window.innerWidth/100)*this.scrollStep[this.xy]);
		var pos = (this.props[this.xy][4]-this.props[this.xy][3]) - wheel*move;

		countMovements.call(this,pos);
	}
}

handyScroller.prototype.scrollMove = function(){
	var pos = this.getMouse()+this.buttonClick;
	countMovements.call(this,pos);
};

function countMovements(pos){
	var newPos = pos<0 ? 0:(pos+this.props[this.xy][9])>this.props[this.xy][8] ? this.props[this.xy][8]-this.props[this.xy][9]:pos;
	var newPosProc = (newPos/this.props[this.xy][8])*100;
	this.elements[this.xy][2].style[this.stylesXY[this.xy][0]] = newPosProc + "%";
	this.refreshMe();

	var scrollProc = (((this.props[this.xy][4]-this.props[this.xy][3])/(this.props[this.xy][8]-this.props[this.xy][9]))*100);
	var boxProc = -(((this.props[this.xy][6]-this.props[this.xy][5])/this.props[this.xy][5])*scrollProc);
	this.contentBox.style[this.stylesXY[this.xy][0]] = boxProc + "%";
}

handyScroller.prototype.refreshMe = function(){
	var changedAr = this.elements[this.xy].slice();
	changedAr.unshift(this.mainBox,this.contentBox);
	for(var x=0,y=0,z=0;x<this.props[this.xy].length;x++){
		this.props[this.xy][x] = changedAr[y].getBoundingClientRect()[this.stylesXY[this.xy][z]];
		y = y===changedAr.length-1 ? 0:++y;
		z = x===(this.props[this.xy].length/2)-1 ? ++z:z;
	};
	this.scrollThick[this.xy] = this.elements[this.xy][0].getBoundingClientRect()[this.stylesXY[this.xy][4]];
};

handyScroller.prototype.prepareToMove = function(){
	var isOnside = !this.stretch[this.xy] ? false:((this.getMouse()>=this.props[this.xy][4]-this.props[this.xy][3]) && (this.getMouse()<this.props[this.xy][4]+this.props[this.xy][9]-this.props[this.xy][3])) ? true:false;
	this.buttonClick = isOnside ? -(this.getMouse()-(this.props[this.xy][4]-this.props[this.xy][3])):-(this.props[this.xy][9]/2);
};

handyScroller.prototype.getMouse = function(){
	var mouseXY = this.xy===0?"clientY":"clientX";
	var mouse = event[mouseXY]<this.props[this.xy][3] ? 0:event[mouseXY]>this.props[this.xy][3]+this.props[this.xy][8] ? this.props[this.xy][8]:event[mouseXY]-this.props[this.xy][3];
	return mouse;
};

handyScroller.prototype.isContentFit = function(xy){
	return (this.props[xy][5]/this.props[xy][6])>=1;
};

handyScroller.prototype.stretchButton = function(){
	if(this.isContentFit(this.xy)){
		this.elements[this.xy][0].style.opacity = "0";
		this.elements[this.xy][1].style.cursor = "default";
		} else {
			this.elements[this.xy][0].style.opacity = "1";
			this.elements[this.xy][1].style.cursor = "pointer";
			if(this.stretch[this.xy]){
				this.elements[this.xy][2].style[this.stylesXY[this.xy][1]] = ((this.props[this.xy][5]/this.props[this.xy][6])*100) + "%";
				} else {
					this.elements[this.xy][2].style[this.stylesXY[this.xy][1]] = null;
					}
			}
};

handyScroller.prototype.setPaddings = function(){
	this.scrollThick = this.divideCorner ? this.scrollThick:[0,0];
	var paddingProc = 100-((this.scrollThick[this.xy]/this.props[this.xy][7])*100);
	this.elements[this.xy][0].style[this.stylesXY[this.xy][1]] = paddingProc+"%";
};<commit_msg>All instructions assigning styles to elements replaced by function setStyles(). IE styling fixed.<commit_after>window.onload = function(){
	var newScroll = new handyScroller({
			box:document.getElementById("panelContent"),
			side: "xy",
			stretch:[true,false],
			divideCorner:true,
			wheelOrient:"horizontally",
			wheelX:30,
			scrollStep:[1,1]
	});
};

function handyScroller(o){
	this.stretch = o.stretch;
	this.buttonClick = null;
	this.divideCorner = o.divideCorner;
	this.side = o.side;
	this.xy = null;
	this.scrollStep = o.scrollStep;
	this.wheelX = o.wheelX;
	this.stylesXY = [["top","height","right","Y","width"],["left","width","bottom","X","height"]];
	this.mainBox = o.box;
	this.contentBox = null;
	this.wheelBox = null;
	this.elements = [[null,  //0: Area		this.elementsY[0]
					  null,  //1: Padding	this.elementsY[1]
					  null], //2: Button	this.elementsY[2]
					 [null,  //0: Area		this.elementsX[0]
					  null,  //1: Padding	this.elementsX[1]
					  null]]; //2: Button	this.elementsX[2]

	this.props = [[null,	 //0: boxTop			this.propsY[0]
				    null,	 //1: contentTop		this.propsY[1]
				    null,	 //2: areaTop			this.propsY[2]
				    null,	 //3: paddingTop		this.propsY[3]
				    null,	 //4: buttonTop			this.propsY[4]
				    null,	 //5: boxHeight			this.propsY[5]
				    null,	 //6: contentHeight		this.propsY[6]
				    null,	 //7: areaHeight		this.propsY[7]
				    null,	 //8: paddingHeight		this.propsY[8]
				    null],	 //9: buttonHeight		this.propsY[9]
				   [null,	 //0: boxLeft			this.propsX[0]
				    null,	 //1: contentLeft		this.propsX[1]
				    null,	 //2: areaLeft			this.propsX[2]
				    null,	 //3: paddingLeft		this.propsX[3]
				    null,	 //4: buttonLeft		this.propsX[4]
				    null,	 //5: boxWidth			this.propsX[5]
				    null,	 //6: contentWidth		this.propsX[6]
				    null,	 //7: areaWidth			this.propsX[7]
				    null,	 //8: paddingWidth		this.propsX[8]
				    null]];	 //9: buttonWidth		this.propsX[9]
	this.scrollThick = [null,null];
	var x = this.side==="y"||this.side==="xy"||this.side==="yx"? 0:1;
	var y = this.side==="x"||this.side==="xy"||this.side==="yx" ? 2:1;

	createBoxes.call(this);
	createWheelEvent.call(this);
	for(;x<y;x++){
		this.xy = x;
		createScrolls.call(this);
		this.refreshMe();
		this.stretchButton();
		this.setPaddings();
	}
	createWheelBox.call(this);
}

function createBoxes(){
	var innerObj = this.mainBox.children;
	var isStatic = window.getComputedStyle(this.mainBox,null).getPropertyValue("position")!=="static"? ["position",null]:["position","relative"];

	setStyles(this.mainBox,["overflow",isStatic[0]],["hidden",isStatic[1]]);
	this.contentBox = document.createElement("DIV");
	this.contentBox.setAttribute("class","handyBox");
	setStyles(this.contentBox,["position"],["relative"]);
	for(;innerObj.length!==0;){
		this.contentBox.appendChild(innerObj[0]);
	}
	this.mainBox.appendChild(this.contentBox);
}

function createScrolls(){
	this.elements[this.xy][0] = document.createElement("DIV");
	this.elements[this.xy][1] = document.createElement("DIV");
	this.elements[this.xy][2] = document.createElement("DIV");

	this.elements[this.xy][0].setAttribute("class","handyScrollBox"+this.stylesXY[this.xy][3]);
	this.elements[this.xy][1].setAttribute("class","handyScrollArea"+this.stylesXY[this.xy][3]);
	this.elements[this.xy][2].setAttribute("class","handyScroller"+this.stylesXY[this.xy][3]);

	setStyles(this.elements[this.xy][0],["position",this.stylesXY[this.xy][0],this.stylesXY[this.xy][2],this.stylesXY[this.xy][1],"boxSizing"],["absolute","0px","0px","100%","border-box"]);
	setStyles(this.elements[this.xy][1],["position","cursor","top","left","width","height","boxSizing","border","padding","margin"],["relative","pointer","0px","0px","100%","100%","border-box","0","0","0"]);
	setStyles(this.elements[this.xy][2],["position"],["relative"]);

	this.elements[this.xy][1].appendChild(this.elements[this.xy][2]);
	this.elements[this.xy][0].appendChild(this.elements[this.xy][1]);
	this.mainBox.appendChild(this.elements[this.xy][0]);

	var clickMe = clickMe.bind(this,this.elements[this.xy][1]);
	var releaseMe = releaseMe.bind(this);
	var scrollMove = this.scrollMove.bind(this);

	this.elements[this.xy][1].addEventListener("mousedown",clickMe);

	function clickMe(obj){
		var checkClass = obj.parentNode.getAttribute("class");
		this.xy = checkClass.charAt(checkClass.length-1)==="Y" ? 0:1;
		this.refreshMe();
		this.prepareToMove();
		this.scrollMove();
		this.refreshMe();
		this.prepareToMove();
		document.body.addEventListener("mouseup",releaseMe);
		document.body.addEventListener("mousemove",scrollMove);
		setStyles(document.body,["cursor"],["pointer"]);
	}

	function releaseMe(){
		document.body.removeEventListener("mouseup",releaseMe);
		document.body.removeEventListener("mousemove",scrollMove);
		setStyles(document.body,["cursor"],["default"]);
	}
}

function createWheelBox(){
	if((!this.isContentFit(1))&&(this.side!=="y")){
		this.wheelBox = document.createElement("DIV");
		this.wheelBox.setAttribute("class","handyWheelBox");
		setStyles(this.wheelBox,["position","right","width"],["absolute","0px",this.wheelX+"%"]);
		this.mainBox.insertBefore(this.wheelBox,this.elements[0][0]);
	}
}

function createWheelEvent(){
	var wheelMe = wheelScroll.bind(this);
	this.mainBox.addEventListener("wheel", wheelMe);
	this.mainBox.addEventListener("mouseover", mouseOverMe);
	this.mainBox.addEventListener("mouseout", mouseOutMe);

	function mouseOverMe(){
		window.onwheel=function(){return false;};
		window.onmousewheel=function(){return false;};
	}

	function mouseOutMe(){
		window.onwheel=null;
		window.onmousewheel=null;
	}

	function wheelScroll(){
		this.xy = 1;
		var side = ((this.getMouse()/this.props[1][5])*100)<(100-this.wheelX) ? 0:1;
		this.xy = side;

		if(this.isContentFit(this.xy)){
			return;
		}

		var e = window.event || e;
		var wheel = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
		var move = this.xy===0 ? ((window.innerHeight/100)*this.scrollStep[this.xy]):((window.innerWidth/100)*this.scrollStep[this.xy]);
		var pos = (this.props[this.xy][4]-this.props[this.xy][3]) - wheel*move;

		countMovements.call(this,pos);
	}
}

handyScroller.prototype.scrollMove = function(){
	var pos = this.getMouse()+this.buttonClick;
	countMovements.call(this,pos);
};

function countMovements(pos){
	var newPos = pos<0 ? 0:(pos+this.props[this.xy][9])>this.props[this.xy][8] ? this.props[this.xy][8]-this.props[this.xy][9]:pos;
	var newPosProc = (newPos/this.props[this.xy][8])*100;
	setStyles(this.elements[this.xy][2],[[this.stylesXY[this.xy][0]]],[newPosProc + "%"]);
	this.refreshMe();

	var scrollProc = (((this.props[this.xy][4]-this.props[this.xy][3])/(this.props[this.xy][8]-this.props[this.xy][9]))*100);
	var boxProc = -(((this.props[this.xy][6]-this.props[this.xy][5])/this.props[this.xy][5])*scrollProc);
	setStyles(this.contentBox,[[this.stylesXY[this.xy][0]]],[boxProc + "%"]);
}

handyScroller.prototype.refreshMe = function(){
	var changedAr = this.elements[this.xy].slice();
	changedAr.unshift(this.mainBox,this.contentBox);
	for(var x=0,y=0,z=0;x<this.props[this.xy].length;x++){
		this.props[this.xy][x] = changedAr[y].getBoundingClientRect()[this.stylesXY[this.xy][z]];
		y = y===changedAr.length-1 ? 0:++y;
		z = x===(this.props[this.xy].length/2)-1 ? ++z:z;
	};
	this.scrollThick[this.xy] = this.elements[this.xy][0].getBoundingClientRect()[this.stylesXY[this.xy][4]];
};

handyScroller.prototype.prepareToMove = function(){
	var isOnside = !this.stretch[this.xy] ? false:((this.getMouse()>=this.props[this.xy][4]-this.props[this.xy][3]) && (this.getMouse()<this.props[this.xy][4]+this.props[this.xy][9]-this.props[this.xy][3])) ? true:false;
	this.buttonClick = isOnside ? -(this.getMouse()-(this.props[this.xy][4]-this.props[this.xy][3])):-(this.props[this.xy][9]/2);
};

handyScroller.prototype.getMouse = function(){
	var mouseXY = this.xy===0?"clientY":"clientX";
	var mouse = event[mouseXY]<this.props[this.xy][3] ? 0:event[mouseXY]>this.props[this.xy][3]+this.props[this.xy][8] ? this.props[this.xy][8]:event[mouseXY]-this.props[this.xy][3];
	return mouse;
};

handyScroller.prototype.isContentFit = function(xy){
	return (this.props[xy][5]/this.props[xy][6])>=1;
};

handyScroller.prototype.stretchButton = function(){
	if(this.isContentFit(this.xy)){
		setStyles(this.elements[this.xy][0],["opacity"],["0"]);
		setStyles(this.elements[this.xy][1],["cursor"],["default"]);

		} else {
			setStyles(this.elements[this.xy][0],["opacity"],["1"]);
			setStyles(this.elements[this.xy][1],["cursor"],["pointer"]);
			if(this.stretch[this.xy]){
				setStyles(this.elements[this.xy][2],[[this.stylesXY[this.xy][1]]],[((this.props[this.xy][5]/this.props[this.xy][6])*100) + "%"]);
				} else {
					setStyles(this.elements[this.xy][2],[[this.stylesXY[this.xy][1]]],[null]);
					}
			}
};

handyScroller.prototype.setPaddings = function(){
	this.scrollThick = this.divideCorner ? this.scrollThick:[0,0];
	var paddingProc = 100-((this.scrollThick[this.xy]/this.props[this.xy][7])*100);
	setStyles(this.elements[this.xy][0],[[this.stylesXY[this.xy][1]]],[paddingProc+"%"]);
};

function setStyles(object,props,vals){
	for(var i=0;i<props.length;i++){
		object.style[props[i]] = vals[i];
	}
}<|endoftext|>


<commit_before>window.onload = function(){
	var newScroll = new handyScroller({
			box:document.getElementById("panelContent"),
			side: "xy",
			stretch:[true,false],
			divideCorner:[false,false],
			scrollMargin:[false,false],
			wheelOrient:"horizontally",
			wheelX:10,
			scrollStep:[1,1]
	});
	var newScroll2 = new handyScroller({
			box:document.getElementById("innerContent"),
			side: "xy",
			stretch:[true,false],
			divideCorner:[false,false],
			scrollMargin:[false,false],
			wheelOrient:"vertically",
			wheelX:30,
			scrollStep:[1,1]
	});
};

function handyScroller(o){
	this.stretch = o.stretch;
	this.divideCorner = o.divideCorner;
	this.scrollMargin = o.scrollMargin;
	this.side = o.side;
	this.scrollStep = o.scrollStep;
	this.wheelOrient = o.wheelOrient;
	this.wheelX = o.wheelX;
	this.mainBox = o.box;
	this.xy = null;
	this.contentBox = null;
	this.wheelBox = null;
	this.scrollId = Date.now();

	this.elements = [[null,  //0: Area		this.elementsY[0]
					  null,  //1: Padding	this.elementsY[1]
					  null], //2: Button	this.elementsY[2]
					 [null,  //0: Area		this.elementsX[0]
					  null,  //1: Padding	this.elementsX[1]
					  null]]; //2: Button	this.elementsX[2]

	this.props = [[null,	 //0: boxTop			this.propsY[0]
				    null,	 //1: contentTop		this.propsY[1]
				    null,	 //2: areaTop			this.propsY[2]
				    null,	 //3: paddingTop		this.propsY[3]
				    null,	 //4: buttonTop			this.propsY[4]
				    null,	 //5: boxHeight			this.propsY[5]
				    null,	 //6: contentHeight		this.propsY[6]
				    null,	 //7: areaHeight		this.propsY[7]
				    null,	 //8: paddingHeight		this.propsY[8]
				    null],	 //9: buttonHeight		this.propsY[9]
				   [null,	 //0: boxLeft			this.propsX[0]
				    null,	 //1: contentLeft		this.propsX[1]
				    null,	 //2: areaLeft			this.propsX[2]
				    null,	 //3: paddingLeft		this.propsX[3]
				    null,	 //4: buttonLeft		this.propsX[4]
				    null,	 //5: boxWidth			this.propsX[5]
				    null,	 //6: contentWidth		this.propsX[6]
				    null,	 //7: areaWidth			this.propsX[7]
				    null,	 //8: paddingWidth		this.propsX[8]
				    null]];	 //9: buttonWidth		this.propsX[9]
	this.scrollThick = [null,null];
	var x = this.side==="y"||this.side==="xy"||this.side==="yx"? 0:1;
	var y = this.side==="x"||this.side==="xy"||this.side==="yx" ? 2:1;

	createBoxes.call(this);
	createWheelEvent.call(this);
	for(;x<y;x++){
		this.xy = x;
		createScrolls.call(this);
		this.refreshMe();
		stretchButton.call(this);
		setPaddings.call(this);
	}
	createWheelBox.call(this);
}

handyScroller.prototype.currentId = null;
handyScroller.prototype.buttonClick = null;
handyScroller.prototype.stylesXY = [["top","height","right","Y","width"],["left","width","bottom","X","height"]];

function createBoxes(){
	var innerObj = this.mainBox.childNodes;
	var isStatic = window.getComputedStyle(this.mainBox,null).getPropertyValue("position")!=="static"? ["position",null]:["position","relative"];

	setStyles(this.mainBox,["overflow",isStatic[0]],["hidden",isStatic[1]]);
	this.contentBox = document.createElement("DIV");
	this.contentBox.setAttribute("class","handyBox");
	setStyles(this.contentBox,["position"],["relative"]);
	for(;innerObj.length!==0;){
		this.contentBox.appendChild(innerObj[0]);
	}
	this.mainBox.appendChild(this.contentBox);
}

function createScrolls(){
	this.elements[this.xy][0] = document.createElement("DIV");
	this.elements[this.xy][1] = document.createElement("DIV");
	this.elements[this.xy][2] = document.createElement("DIV");

	this.elements[this.xy][0].setAttribute("class","handyScrollBox"+this.stylesXY[this.xy][3]);
	this.elements[this.xy][1].setAttribute("class","handyScrollArea"+this.stylesXY[this.xy][3]);
	this.elements[this.xy][2].setAttribute("class","handyScroller"+this.stylesXY[this.xy][3]);

	setStyles(this.elements[this.xy][0],["position",this.stylesXY[this.xy][0],this.stylesXY[this.xy][2],this.stylesXY[this.xy][1],"boxSizing"],["absolute","0px","0px","100%","border-box"]);
	setStyles(this.elements[this.xy][1],["position","cursor","top","left","width","height","boxSizing","border","padding","margin"],["relative","pointer","0px","0px","100%","100%","border-box","0","0","0"]);
	setStyles(this.elements[this.xy][2],["position"],["relative"]);

	this.elements[this.xy][1].appendChild(this.elements[this.xy][2]);
	this.elements[this.xy][0].appendChild(this.elements[this.xy][1]);
	this.mainBox.appendChild(this.elements[this.xy][0]);

	var clickMe = clickMe.bind(this,this.elements[this.xy][1]);
	var releaseMe = releaseMe.bind(this);
	var scrollM = scrollMove.bind(this);

	this.elements[this.xy][1].addEventListener("mousedown",clickMe);

	function clickMe(obj){
		var checkClass = obj.parentNode.getAttribute("class");
		this.xy = checkClass.charAt(checkClass.length-1)==="Y" ? 0:1;
		this.refreshMe();
		prepareToMove.call(this);
		scrollMove.call(this);
		this.refreshMe();
		prepareToMove.call(this);
		document.body.addEventListener("mouseup",releaseMe);
		document.body.addEventListener("mousemove",scrollM);
		setStyles(document.body,["cursor"],["pointer"]);
		setStyles(this.contentBox,["webkitTouchCallout","webkitUserSelect","khtmlUserSelect","mozUserSelect","msUserSelect","oUserSelect","UserSelect"],["none","none","none","none","none","none","none"]);
	}

	function releaseMe(){
		document.body.removeEventListener("mouseup",releaseMe);
		document.body.removeEventListener("mousemove",scrollM);
		setStyles(document.body,["cursor"],["default"]);
		setStyles(this.contentBox,["webkitTouchCallout","webkitUserSelect","khtmlUserSelect","mozUserSelect","msUserSelect","oUserSelect","UserSelect"],["all","all","all","all","all","all","all"]);
	}
}

function createWheelBox(){
	if((!isContentFit.call(this,1))&&(this.side!=="y")&&(this.side!=="x")&&(this.wheelX!==0)){
		this.wheelBox = document.createElement("DIV");
		this.wheelBox.setAttribute("class","handyWheelBox");
		if(this.wheelOrient==="vertically"){
			setStyles(this.wheelBox,["position","pointerEvents","bottom","height"],["absolute","none","0px",this.wheelX+"%"]);
			} else {
				setStyles(this.wheelBox,["position","pointerEvents","right","width"],["absolute","none","0px",this.wheelX+"%"]);
				}
		this.mainBox.insertBefore(this.wheelBox,this.elements[0][0]);
	} else {
		this.wheelX = 0;
	}
}

function createWheelEvent(){
	var wheelMe = wheelScroll.bind(this);
	var bOver = mouseOverMe.bind(this);
	this.mainBox.addEventListener("wheel", wheelMe);
	this.mainBox.addEventListener("mouseover",bOver,true);
	this.mainBox.addEventListener("mouseout", mouseOutMe,true);

	function mouseOverMe(){
		window.onwheel=function(){return false;};
		window.onmousewheel=function(){return false;};
		this.constructor.prototype.currentId = this.scrollId;
	}

	function mouseOutMe(){
		window.onwheel=null;
		window.onmousewheel=null;
	}

	function wheelScroll(){
		if(this.scrollId!==this.constructor.prototype.currentId){
			return;
		}

		this.xy = this.wheelOrient === "vertically" ? 0:1;
		var side = ((getMouse.call(this)/this.props[this.xy][5])*100)<(100-this.wheelX) ? 0:1;
		this.xy = this.side==="x" ? 1:this.side==="y" ? 0:side;
		if(isContentFit.call(this,this.xy)){
			return;
		}

		var e = window.event || e;
		var wheel = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
		var move = this.xy===0 ? ((window.innerHeight/100)*this.scrollStep[this.xy]):((window.innerWidth/100)*this.scrollStep[this.xy]);
		var pos = (this.props[this.xy][4]-this.props[this.xy][3]) - wheel*move;

		countMovements.call(this,pos);
	}
}

function scrollMove(){
	var pos = getMouse.call(this)+this.buttonClick;
	countMovements.call(this,pos);
};

function countMovements(pos){
	var newPos = pos<0 ? 0:(pos+this.props[this.xy][9])>this.props[this.xy][8] ? this.props[this.xy][8]-this.props[this.xy][9]:pos;
	var newPosProc = (newPos/this.props[this.xy][8])*100;
	setStyles(this.elements[this.xy][2],[[this.stylesXY[this.xy][0]]],[newPosProc + "%"]);
	this.refreshMe();
	var scrollMargin = this.scrollMargin[this.xy] ? this.scrollThick:[0,0];
	var scrollProc = (((this.props[this.xy][4]-this.props[this.xy][3])/(this.props[this.xy][8]-this.props[this.xy][9]))*100);
	var boxProc = -(((this.props[this.xy][6]+scrollMargin[this.xy]-this.props[this.xy][5])/this.props[this.xy][5])*scrollProc);
	setStyles(this.contentBox,[[this.stylesXY[this.xy][0]]],[boxProc + "%"]);
}

handyScroller.prototype.refreshMe = function(){
	var changedAr = this.elements[this.xy].slice();
	changedAr.unshift(this.mainBox,this.contentBox);
	for(var x=0,y=0,z=0;x<this.props[this.xy].length;x++){
		this.props[this.xy][x] = changedAr[y].getBoundingClientRect()[this.stylesXY[this.xy][z]];
		y = y===changedAr.length-1 ? 0:++y;
		z = x===(this.props[this.xy].length/2)-1 ? ++z:z;
	};
	this.scrollThick[this.xy] = this.elements[this.xy][0].getBoundingClientRect()[this.stylesXY[this.xy][4]];
};

function prepareToMove(){
	var isOnside = !this.stretch[this.xy] ? false:((getMouse.call(this)>=this.props[this.xy][4]-this.props[this.xy][3]) && (getMouse.call(this)<this.props[this.xy][4]+this.props[this.xy][9]-this.props[this.xy][3])) ? true:false;
	this.buttonClick = isOnside ? -(getMouse.call(this)-(this.props[this.xy][4]-this.props[this.xy][3])):-(this.props[this.xy][9]/2);
};

function getMouse(){
	var mouseXY = this.xy===0?"clientY":"clientX";
	var mouse = event[mouseXY]<this.props[this.xy][3] ? 0:event[mouseXY]>this.props[this.xy][3]+this.props[this.xy][8] ? this.props[this.xy][8]:event[mouseXY]-this.props[this.xy][3];
	return mouse;
}

function isContentFit(xy){
	return (this.props[xy][5]/this.props[xy][6])>=1;
}

function stretchButton(){
	if(isContentFit.call(this,this.xy)){
		setStyles(this.elements[this.xy][0],["opacity"],["0"]);
		setStyles(this.elements[this.xy][1],["cursor"],["default"]);

		} else {
			setStyles(this.elements[this.xy][0],["opacity"],["1"]);
			setStyles(this.elements[this.xy][1],["cursor"],["pointer"]);
			if(this.stretch[this.xy]){
				setStyles(this.elements[this.xy][2],[[this.stylesXY[this.xy][1]]],[((this.props[this.xy][5]/this.props[this.xy][6])*100) + "%"]);
				} else {
					setStyles(this.elements[this.xy][2],[[this.stylesXY[this.xy][1]]],[null]);
					}
			}
}

function setPaddings(){
	var scrollThick = this.divideCorner[this.xy] ? this.scrollThick:[0,0];
	var paddingProc = 100-((scrollThick[this.xy]/this.props[this.xy][7])*100);
	setStyles(this.elements[this.xy][0],[[this.stylesXY[this.xy][1]]],[paddingProc+"%"]);
}

function setStyles(object,props,vals){
	for(var i=0;i<props.length;i++){
		object.style[props[i]] = vals[i];
	}
}<commit_msg>Function converting scrollTop and scrollLeft values into contentBox top and left css properties added.<commit_after>window.onload = function(){
	var newScroll = new handyScroller({
			box:document.getElementById("panelContent"),
			side: "xy",
			stretch:[true,true],
			divideCorner:[false,false],
			scrollMargin:[true,true],
			wheelOrient:"horizontally",
			wheelX:10,
			scrollStep:[1,1]
	});
	var newScroll2 = new handyScroller({
			box:document.getElementById("innerContent"),
			side: "xy",
			stretch:[false,false],
			divideCorner:[false,false],
			scrollMargin:[true,true],
			wheelOrient:"vertically",
			wheelX:30,
			scrollStep:[1,1]
	});
};

function handyScroller(o){
	this.stretch = o.stretch;
	this.divideCorner = o.divideCorner;
	this.scrollMargin = o.scrollMargin;
	this.side = o.side;
	this.scrollStep = o.scrollStep;
	this.wheelOrient = o.wheelOrient;
	this.wheelX = o.wheelX;
	this.mainBox = o.box;
	this.xy = null;
	this.contentBox = null;
	this.wheelBox = null;
	this.scrollId = Date.now();

	this.elements = [[null,   //Area		this.elements[0][0]
					  null,   //Padding		this.elements[0][1]
					  null],  //Button		this.elements[0][2]
					 [null,   //Area		this.elements[1][0]
					  null,   //Padding		this.elements[1][1]
					  null]]; //Button		this.elements[1][2]

	this.props = [[null,	 //boxTop			this.props[0][0]
				    null,	 //contentTop		this.props[0][1]
				    null,	 //areaTop			this.props[0][2]
				    null,	 //paddingTop		this.props[0][3]
				    null,	 //buttonTop		this.props[0][4]
				    null,	 //boxHeight		this.props[0][5]
				    null,	 //contentHeight	this.props[0][6]
				    null,	 //areaHeight		this.props[0][7]
				    null,	 //paddingHeight	this.props[0][8]
				    null],	 //buttonHeight		this.props[0][9]
				   [null,	 //boxLeft			this.props[1][0]
				    null,	 //contentLeft		this.props[1][1]
				    null,	 //areaLeft			this.props[1][2]
				    null,	 //paddingLeft		this.props[1][3]
				    null,	 //buttonLeft		this.props[1][4]
				    null,	 //boxWidth			this.props[1][5]
				    null,	 //contentWidth		this.props[1][6]
				    null,	 //areaWidth		this.props[1][7]
				    null,	 //paddingWidth		this.props[1][8]
				    null]];	 //buttonWidth		this.props[1][9]
	this.scrollThick = [null,null];
	this.scrollEv = [0,0];

	var x = this.side==="y"||this.side==="xy"||this.side==="yx"? 0:1;
	var y = this.side==="x"||this.side==="xy"||this.side==="yx" ? 2:1;

	createBoxes.call(this);
	createWheelEvent.call(this);
	for(;x<y;x++){
		this.xy = x;
		createScrolls.call(this);
		stretchButton.call(this);
		setPaddings.call(this);
	}
	createWheelBox.call(this);
	blockScroll.call(this);
}

handyScroller.prototype.currentId = null;
handyScroller.prototype.buttonClick = null;
handyScroller.prototype.stylesXY = [["top","height","right","Y","width","scrollTop"],["left","width","bottom","X","height","scrollLeft"]];

function createBoxes(){
	var innerObj = this.mainBox.childNodes;
	var isStatic = window.getComputedStyle(this.mainBox,null).getPropertyValue("position")!=="static"? ["position",null]:["position","relative"];
	setStyles(this.mainBox,["overflow",isStatic[0]],["hidden",isStatic[1]]);
	this.contentBox = document.createElement("DIV");
	this.contentBox.setAttribute("class","handyBox");
	setStyles(this.contentBox,["position"],["relative"]);
	for(;innerObj.length!==0;){
		this.contentBox.appendChild(innerObj[0]);
	}
	this.mainBox.appendChild(this.contentBox);
}

function createScrolls(){
	this.elements[this.xy][0] = document.createElement("DIV");
	this.elements[this.xy][1] = document.createElement("DIV");
	this.elements[this.xy][2] = document.createElement("DIV");

	this.elements[this.xy][0].setAttribute("class","handyScrollBox"+this.stylesXY[this.xy][3]);
	this.elements[this.xy][1].setAttribute("class","handyScrollArea"+this.stylesXY[this.xy][3]);
	this.elements[this.xy][2].setAttribute("class","handyScroller"+this.stylesXY[this.xy][3]);

	setStyles(this.elements[this.xy][0],["position",this.stylesXY[this.xy][0],this.stylesXY[this.xy][2],this.stylesXY[this.xy][1],"boxSizing"],["absolute","0px","0px","100%","border-box"]);
	setStyles(this.elements[this.xy][1],["position","cursor","top","left","width","height","boxSizing","border","padding","margin"],["relative","pointer","0px","0px","100%","100%","border-box","0","0","0"]);
	setStyles(this.elements[this.xy][2],["position"],["relative"]);

	this.elements[this.xy][1].appendChild(this.elements[this.xy][2]);
	this.elements[this.xy][0].appendChild(this.elements[this.xy][1]);
	this.mainBox.appendChild(this.elements[this.xy][0]);

	var clickMe = clickMe.bind(this,this.elements[this.xy][1]);
	var releaseMe = releaseMe.bind(this);
	var scrollM = scrollMove.bind(this);

	this.elements[this.xy][1].addEventListener("mousedown",clickMe);
	this.refreshMe();

	function clickMe(obj){
		var checkClass = obj.parentNode.getAttribute("class");
		this.xy = checkClass.charAt(checkClass.length-1)==="Y" ? 0:1;
		prepareToMove.call(this);
		scrollMove.call(this);
		prepareToMove.call(this);
		document.body.addEventListener("mouseup",releaseMe);
		document.body.addEventListener("mousemove",scrollM);
		setStyles(document.body,["cursor"],["pointer"]);
		setStyles(this.contentBox,["webkitTouchCallout","webkitUserSelect","khtmlUserSelect","mozUserSelect","msUserSelect","oUserSelect","UserSelect"],["none","none","none","none","none","none","none"]);
	}

	function releaseMe(){
		document.body.removeEventListener("mouseup",releaseMe);
		document.body.removeEventListener("mousemove",scrollM);
		setStyles(document.body,["cursor"],["default"]);
		setStyles(this.contentBox,["webkitTouchCallout","webkitUserSelect","khtmlUserSelect","mozUserSelect","msUserSelect","oUserSelect","UserSelect"],["all","all","all","all","all","all","all"]);
	}
}

function createWheelBox(){
	if((!isContentFit.call(this,1))&&(this.side!=="y")&&(this.side!=="x")&&(this.wheelX!==0)){
		this.wheelBox = document.createElement("DIV");
		this.wheelBox.setAttribute("class","handyWheelBox");
		if(this.wheelOrient==="vertically"){
			setStyles(this.wheelBox,["position","pointerEvents","bottom","height"],["absolute","none","0px",this.wheelX+"%"]);
			} else {
				setStyles(this.wheelBox,["position","pointerEvents","right","width"],["absolute","none","0px",this.wheelX+"%"]);
				}
		this.mainBox.insertBefore(this.wheelBox,this.elements[0][0]);
	} else {
		this.wheelX = 0;
	}
}

function createWheelEvent(){
	var wheelMe = wheelScroll.bind(this);
	var bOver = mouseOverMe.bind(this);
	this.mainBox.addEventListener("wheel", wheelMe);
	this.mainBox.addEventListener("mouseover",bOver,true);
	this.mainBox.addEventListener("mouseout", mouseOutMe,true);

	function mouseOverMe(){
		window.onwheel=function(){return false;};
		window.onmousewheel=function(){return false;};
		this.constructor.prototype.currentId = this.scrollId;
	}

	function mouseOutMe(){
		window.onwheel=null;
		window.onmousewheel=null;
	}

	function wheelScroll(){
		if(this.scrollId!==this.constructor.prototype.currentId){
			return;
		}

		this.xy = this.wheelOrient === "vertically" ? 0:1;
		var side = ((getMouse.call(this)/this.props[this.xy][5])*100)<(100-this.wheelX) ? 0:1;
		this.xy = this.side==="x" ? 1:this.side==="y" ? 0:side;
		if(isContentFit.call(this,this.xy)){
			return;
		}

		var e = window.event || e;
		var wheel = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
		var move = this.xy===0 ? ((window.innerHeight/100)*this.scrollStep[this.xy]):((window.innerWidth/100)*this.scrollStep[this.xy]);
		var pos = (this.props[this.xy][4]-this.props[this.xy][3]) - wheel*move;
		countMovements.call(this,pos);
	}
}

function getMouse(){
	var mouseXY = this.xy===0?"clientY":"clientX";
	this.refreshMe();
	var mouse = event[mouseXY]<this.props[this.xy][3] ? 0:event[mouseXY]>this.props[this.xy][3]+this.props[this.xy][8] ? this.props[this.xy][8]:event[mouseXY]-this.props[this.xy][3];
	return mouse;
}

function scrollMove(){
	var pos = getMouse.call(this)+this.buttonClick;
	countMovements.call(this,pos);
}

function blockScroll(){
	var binded = blockMe.bind(this);
	this.mainBox.addEventListener("scroll",binded);

	function blockMe(){
		if(this.mainBox.scrollLeft!==0){
			countScroll.call(this,1,this.mainBox.scrollLeft);
			this.mainBox.scrollLeft = 0;
		}
		if(this.mainBox.scrollTop!==0){
			countScroll.call(this,0,this.mainBox.scrollTop);
			this.mainBox.scrollTop = 0;
		}
	}
}

function countScroll(xy,scroll){
	this.xy = xy;
	this.refreshMe();
	var scrollMargin = this.xy===0 && this.scrollMargin[this.xy] ? this.scrollThick:[0,0];
	var pos = ((scroll)/(this.props[this.xy][6]+scrollMargin[this.xy]-(this.props[this.xy][5])));
	var butPx = (this.props[this.xy][8]-this.props[this.xy][9])*pos;
	countMovements.call(this,butPx);
}

function countMovements(pos){
	var newPos = pos<0 ? 0:(pos+this.props[this.xy][9])>this.props[this.xy][8] ? this.props[this.xy][8]-this.props[this.xy][9]:pos;
	var newPosProc = (newPos/this.props[this.xy][8])*100;
	setStyles(this.elements[this.xy][2],[[this.stylesXY[this.xy][0]]],[newPosProc + "%"]);
	this.refreshMe();
	var scrollMargin = this.scrollMargin[this.xy] ? this.scrollThick:[0,0];
	var scrollProc = (((this.props[this.xy][4]-this.props[this.xy][3])/(this.props[this.xy][8]-this.props[this.xy][9]))*100);
	var boxProc = -(((this.props[this.xy][6]+scrollMargin[this.xy]-this.props[this.xy][5])/this.props[this.xy][5])*scrollProc);
	setStyles(this.contentBox,[[this.stylesXY[this.xy][0]]],[boxProc + "%"]);
}

handyScroller.prototype.refreshMe = function(){
	var changedAr = this.elements[this.xy].slice();
	changedAr.unshift(this.mainBox,this.contentBox);
	for(var x=0,y=0,z=0;x<this.props[this.xy].length;x++){
		this.props[this.xy][x] = changedAr[y].getBoundingClientRect()[this.stylesXY[this.xy][z]];
		y = y===changedAr.length-1 ? 0:++y;
		z = x===(this.props[this.xy].length/2)-1 ? ++z:z;
	};
	this.scrollThick[1-this.xy] = this.elements[this.xy][0].getBoundingClientRect()[this.stylesXY[this.xy][4]];
};

function prepareToMove(){
	this.refreshMe();
	var isOnside = !this.stretch[this.xy] ? false:((getMouse.call(this)>=this.props[this.xy][4]-this.props[this.xy][3]) && (getMouse.call(this)<this.props[this.xy][4]+this.props[this.xy][9]-this.props[this.xy][3])) ? true:false;
	this.buttonClick = isOnside ? -(getMouse.call(this)-(this.props[this.xy][4]-this.props[this.xy][3])):-(this.props[this.xy][9]/2);
};

function isContentFit(xy){
	return (this.props[xy][5]/this.props[xy][6])>=1;
}

function stretchButton(){
	if(isContentFit.call(this,this.xy)){
		setStyles(this.elements[this.xy][0],["opacity"],["0"]);
		setStyles(this.elements[this.xy][1],["cursor"],["default"]);

		} else {
			setStyles(this.elements[this.xy][0],["opacity"],["1"]);
			setStyles(this.elements[this.xy][1],["cursor"],["pointer"]);
			if(this.stretch[this.xy]){
				setStyles(this.elements[this.xy][2],[[this.stylesXY[this.xy][1]]],[((this.props[this.xy][5]/this.props[this.xy][6])*100) + "%"]);
				this.refreshMe();
				} else {
					setStyles(this.elements[this.xy][2],[[this.stylesXY[this.xy][1]]],[null]);
					}
			}
}

function setPaddings(){
	var scrollThick = this.divideCorner[this.xy] ? this.scrollThick:[0,0];
	var paddingProc = 100-((scrollThick[this.xy]/this.props[this.xy][7])*100);
	setStyles(this.elements[this.xy][0],[[this.stylesXY[this.xy][1]]],[paddingProc+"%"]);
	this.refreshMe();
}

function setStyles(object,props,vals){
	for(var i=0;i<props.length;i++){
		object.style[props[i]] = vals[i];
	}
}<|endoftext|>


<commit_before>const fs = require('fs')
const Path = require('path')
const R = require('ramda')
const nodePromise = require('./nodePromise')
const hashFile = require('./hashFile')
const { indexFileName } = require('./constants')

const combineNamesAndValues = R.zipWith((name, value) => R.cond([
    [R.has('hash'), R.merge({ name })],
    [R.T, R.prop('children')]
])(value))

function hashChild(basePath, fileName, prefix) {
    const filePath = Path.join(basePath, fileName)

    return nodePromise(callback => {
        fs.lstat(filePath, callback)
    })
    .then(
        R.cond([
            [stats => stats.isFile(), stats => (
                hashFile(filePath)
                .then(hash => ({
                    hash,
                    bytes: stats.size
                }))
            )],
            [stats => stats.isDirectory(), R.always(
                hashDirectory(filePath, Path.join(prefix, fileName))
                .then(R.objOf('children'))
            )]
        ])
    )
}

function hashDirectory(path, prefix = '') {
    return nodePromise(callback => {
        fs.readdir(path, callback)
    })
    .then(R.reject(R.anyPass([ // Ignore the following:
        R.test(/^\./), // .DS_Store, .*
        R.equals(indexFileName) // index.collected
    ])))
    .then(childNames =>
        Promise.all(childNames.map(fileName =>
            hashChild(path, fileName, prefix)
        ))
        .then(R.pipe(
            R.reject(R.isNil),
            combineNamesAndValues(R.map(
                childName => Path.join(prefix, childName),
            childNames)),
            R.flatten
        ))
    )
}

module.exports = hashDirectory
<commit_msg>Rename hash to explicitly sha256<commit_after>const fs = require('fs')
const Path = require('path')
const R = require('ramda')
const nodePromise = require('./nodePromise')
const hashFile = require('./hashFile')
const { indexFileName } = require('./constants')

const combineNamesAndValues = R.zipWith((name, value) => R.cond([
    [R.has('sha256'), R.merge({ name })],
    [R.T, R.prop('children')]
])(value))

function hashChild(basePath, fileName, prefix) {
    const filePath = Path.join(basePath, fileName)

    return nodePromise(callback => {
        fs.lstat(filePath, callback)
    })
    .then(
        R.cond([
            [stats => stats.isFile(), stats => (
                hashFile(filePath)
                .then(hash => ({
                    sha256: hash,
                    bytes: stats.size
                }))
            )],
            [stats => stats.isDirectory(), R.always(
                hashDirectory(filePath, Path.join(prefix, fileName))
                .then(R.objOf('children'))
            )]
        ])
    )
}

function hashDirectory(path, prefix = '') {
    return nodePromise(callback => {
        fs.readdir(path, callback)
    })
    .then(R.reject(R.anyPass([ // Ignore the following:
        R.test(/^\./), // .DS_Store, .*
        R.equals(indexFileName) // index.collected
    ])))
    .then(childNames =>
        Promise.all(childNames.map(fileName =>
            hashChild(path, fileName, prefix)
        ))
        .then(R.pipe(
            R.reject(R.isNil),
            combineNamesAndValues(R.map(
                childName => Path.join(prefix, childName),
            childNames)),
            R.flatten
        ))
    )
}

module.exports = hashDirectory
<|endoftext|>


<commit_before>var auth2;
// client ID is generated from my google APIs credentials page.
const CLIENT_ID = '1034390229233-u07o0iaas2oql8l4jhe7fevpfsbrtv7n.apps.googleusercontent.com'
// googleUser is generated with auth2.currentUser.get().
// Further Google Sign in documentation is available at:
// https://developers.google.com/identity/sign-in/web/reference

function getId() {
  return auth2.currentUser.get().getId();
}

/**
 * Loads the auth2 library for the g-signin API, and then initializes
 * the googleAuth object.
 * Passed as jquery parameter, executed by API script.
 */
function onStart() {
  gapi.load('auth2', initSigninV2);
}

/**
 * Initializes google authentication API and sets event listeners.
 */
function initSigninV2() {
  auth2 = gapi.auth2.init({
    client_id : CLIENT_ID
  });

  gapi.signin2.render('g-signin-container');

  auth2.currentUser.listen(function(newGoogleUser) {
    if (auth2.isSignedIn.get()) {
      insertUserInfo(newGoogleUser);
    }
  });

  auth2.isSignedIn.listen(function(signedIn) {
    if (signedIn) {
      enableUserDropdown();
    } else {
      disableUserDropdown();
    }
  });
}

/**
 * Signs out current user from g-signin API.
 */
function signOut() {
  auth2.signOut();
}

/**
 * To be run in currentUser listener, activates whenever current user changes.
 *
 * @param {GoogleUser} current user to provide profile info.
 */
function insertUserInfo(googleUser) {
  // Insert user name into user-page anchor
  let text = googleUser.getBasicProfile().getGivenName() + '\'s Page';
  const userPageAnchor = document.getElementById('user-page-anchor');
  userPageAnchor.innerText = text;
}

function enableUserDropdown() {
  const dropdown = document.querySelector('.dropdown');
  dropdown.addEventListener('mouseover', showDropdown = function() {
    dropdown.querySelector('.dropdown-content').style.display = 'block';
  });
  dropdown.addEventListener('mouseleave', hideDropdown = function() {
    dropdown.querySelector('.dropdown-content').style.display = 'none';
  });
}

function disableUserDropdown() {
  const dropdown = document.querySelector('.dropdown');
  dropdown.removeEventListener('mouseover', showDropdown);
  dropdown.removeEventListener('mouseleave', hideDropdown);
  dropdown.querySelector('.dropdown-content').style.display = 'none';
}

/**
 * Provides a sign-in popup if user is signed out,
 * returns a promise when user is signed in.
 *
 */
function confirmUser() {
  return new Promise((resolve, reject) => {
    if (!auth2.isSignedIn.get()) {
      auth2.signIn().then(resolve).catch(reject);
    } else {
      resolve();
    }
  })
}
<commit_msg>change function getID to getIdToken (explanation in function comment)<commit_after>var auth2;
// client ID is generated from my google APIs credentials page.
const CLIENT_ID = '1034390229233-u07o0iaas2oql8l4jhe7fevpfsbrtv7n.apps.googleusercontent.com'

// googleUser is generated with auth2.currentUser.get().
// Further Google Sign in documentation is available at:
// https://developers.google.com/identity/sign-in/web/reference

/**
 * This ID token is an encrypted token containing user information,
 * including user unique ID and profile data.
 * ID token must be sent to backend for processing for any user-related datastore operation.
 */
function getIdToken() {
  return auth2.currentUser.get().getAuthResponse().id_token;
}

/**
 * Loads the auth2 library for the g-signin API, and then initializes
 * the googleAuth object.
 * Passed as jquery parameter, executed by API script.
 */
function onStart() {
  gapi.load('auth2', initSigninV2);
}

/**
 * Initializes google authentication API and sets event listeners.
 */
function initSigninV2() {
  auth2 = gapi.auth2.init({
    client_id : CLIENT_ID
  });

  gapi.signin2.render('g-signin-container');

  auth2.currentUser.listen(function(newGoogleUser) {
    if (auth2.isSignedIn.get()) {
      insertUserInfo(newGoogleUser);
    }
  });

  auth2.isSignedIn.listen(function(signedIn) {
    if (signedIn) {
      enableUserDropdown();
    } else {
      disableUserDropdown();
    }
  });
}

/**
 * Signs out current user from g-signin API.
 */
function signOut() {
  auth2.signOut();
}

/**
 * To be run in currentUser listener, activates whenever current user changes.
 *
 * @param {GoogleUser} current user to provide profile info.
 */
function insertUserInfo(googleUser) {
  // Insert user name into user-page anchor
  let text = googleUser.getBasicProfile().getGivenName() + '\'s Page';
  const userPageAnchor = document.getElementById('user-page-anchor');
  userPageAnchor.innerText = text;
}

function enableUserDropdown() {
  const dropdown = document.querySelector('.dropdown');
  dropdown.addEventListener('mouseover', showDropdown = function() {
    dropdown.querySelector('.dropdown-content').style.display = 'block';
  });
  dropdown.addEventListener('mouseleave', hideDropdown = function() {
    dropdown.querySelector('.dropdown-content').style.display = 'none';
  });
}

function disableUserDropdown() {
  const dropdown = document.querySelector('.dropdown');
  dropdown.removeEventListener('mouseover', showDropdown);
  dropdown.removeEventListener('mouseleave', hideDropdown);
  dropdown.querySelector('.dropdown-content').style.display = 'none';
}

/**
 * Provides a sign-in popup if user is signed out,
 * returns a promise when user is signed in.
 *
 */
function confirmUser() {
  return new Promise((resolve, reject) => {
    if (!auth2.isSignedIn.get()) {
      auth2.signIn().then(resolve).catch(reject);
    } else {
      resolve();
    }
  })
}
<|endoftext|>


<commit_before>/*
 * WTF Engine
 * https://github.com/soulwire/WTFEngine
 *
 * Copyright 2011, Justin Windle
 * http://blog.soulwire.co.uk/
 * Code Licensed under the MIT licence.
 * https://github.com/soulwire/WTFEngine/blob/master/MIT-LICENSE.txt
 *
 * Concept based on WTFSIMFD
 * http://whatthefuckshouldimakefordinner.com/
 * by Zach Golden
 * http://www.zachgolden.com/
 *
 */

var templates = [
"@who in a @context world, @verb with a @adjective @noun."

];

var phrases = [
	"The date is 2024. Imagine",
	"In 10 years, you'll see",
	"This is your future:"
];

var labels = [
	"What else might the future bring?",
  "This is crazy, show me another!"
];

/*
	Auto Generated from WTF.csv
*/

corpus = {};

corpus.who		 = ["A homeless man", "Librarians", "Dinosaurs", "I am", "Communities", "Doctors", "Taxi drivers", "Darth Vader", "An astronaut", "Scientists", "A psychologist", "Adversarial Robots", "Mutants", "My grand grand future son", "Alien colonization", "Revived Walt Disney", "Elephants", "Drones", "Barack Obama", "Jimmy Carter", "An abolitionist", "Youth", "Business people", "Women", "Dali Lama", "Aliens", "Coders", "Teachers", "Me", "Artichokes", "Super Germs", "Talking animals", "Robots", "Haters", "Punks", "Ross", "Doppelgangers", "Enemies", "children", "Microbes", "Grandma", "Elders", "My clone", "A fireman", "farmers", "Sarah", "A Middle Schooler", "A Waitress", "Artists", "The Neighborhood Drone" , "Beekeepers" , "Simba" , "Monkeys" , "Futuristas"];

corpus.context		 = ["diseased", "strange", "desperate", "invisible", "borderless", "flooded", "dry", "crowded", "competitive", "open sourced", "cooperative", "collaborative", "depressing", "empowering", "inspiring", "loved", "crowded", "chaotic", "weird", "anticipatory", "busy", "forgiving", "judgemental", "scary", "bedazzled", "dormant", "unstable", "satisfactory", "virtual", "expansive", "isolated", "fun", "inclusive", "hot","challenging", "collaborative", "connected", "highly organized", "sustainable", "wholly unfamiliar", "regulated", "adversarial", "friendly", "community-oriented" ];

corpus.verb			 = ["being watched", "gathering information", "gardening", "stalking birds", "blogging", "harvesting", "organizing", "eating", "dreaming", "philosophizing", "peacemaking", "rendering", "laughing", "sharing", "dstroying", "running", "owning", "speaking", "dancing", "sleeping", "ritualizing", "smelling", "vacationing", "living", "celebrating", "dying", "creating","running", "touching", "tasting", "smelling", "hearing", "seeing", "using telepathy", "designing interactions", "driving", "singing", "blogging","browsing","chatting","file sharing","gaming","hacking","microblogging","sharing","shopping","syncing"];

corpus.adjective	 = ["time traveling", "glocal", "green", "intense", "lab grown", "isolated", "artisinal", "organic", "free range", "family owned", "musical", "resilient", "quality", "implanted", "organic", "compartmentalized", "fresh", "genetically engineered", "composted", "teleported", "nourishing", "sentient", "healthy", "four dimensional", "audio reactive","collaborative","compressed","cross-platform","crowdsourced","distributed","dynamic","generative","gesture controlled","integrated","lightweight","locally executing","memcached","monetized","motion controlled","open source","optimised","micro", "nano", "swarming", "smart", "emergent", "disruptive", "crowdsourced", "increasingly available", "augmented", "hyper-local", "distributed"];

corpus.noun			 = ["surveillance camera", "borth control", "gestural interface", "set of glasses", "ticket", "backpack", "kitchen sink", "internal music device", "shelf", "health checkup screen", "robot-sourced disco bootie", "beard", "monkey", "tea pot", "space craft", "screw driver", "glue gun", "power tool", "slime", "wand", "skate board", "pen", "scooter", "soil", "tree", "earth", "space", "statistic", "microchip", "building", "fly trap", "time machine", "water bottle", "moon", "internal bionic body part", "cyborg plant", "communication device", "necklace", "submarine", "banana", "hamburger", "toothbrush", "water slide", "snake pit", "farm", "home", "tomato", "phone", "jetpack", "car", "book", "plant", "fork and knife", "set of chopsticks", "hat", "street sign"];
<commit_msg>Update corpus.js<commit_after>/*
 * WTF Engine
 * https://github.com/soulwire/WTFEngine
 *
 * Copyright 2011, Justin Windle
 * http://blog.soulwire.co.uk/
 * Code Licensed under the MIT licence.
 * https://github.com/soulwire/WTFEngine/blob/master/MIT-LICENSE.txt
 *
 * Concept based on WTFSIMFD
 * http://whatthefuckshouldimakefordinner.com/
 * by Zach Golden
 * http://www.zachgolden.com/
 *
 */

var templates = [
"@who in a @context world, @verb with a @adjective @noun."

];

var phrases = [
	"The date is 2024. Imagine",
	"In 10 years, you'll see",
	"This is your future:"
];

var labels = [
	"What else might the future bring?",
  "This is crazy, show me another!"
];

/*
	Auto Generated from WTF.csv
*/

corpus = {};

corpus.who = ["Artists", "The Neighborhood Drone" , "Beekeepers", "A homeless man", "Librarians", "Dinosaurs", "I am", "Communities", "Doctors", "Taxi drivers", "Darth Vader", "An astronaut", "Scientists", "A psychologist", "Adversarial Robots", "Mutants", "My grand grand future son", "Alien colonization", "Revived Walt Disney", "Elephants", "Drones", "Barack Obama", "Jimmy Carter", "An abolitionist", "Youth", "Business people", "Women", "Dali Lama", "Aliens", "Coders", "Teachers", "Me", "Artichokes", "Super Germs", "Talking animals", "Robots", "Haters", "Punks", "Ross", "Doppelgängers", "Enemies", "Children", "Microbes", "Grandma", "Elders", "My clone", "A fireman", "Farmers", "Sarah", "A Middle Schooler", "A Waitress" , "Simba" , "Monkeys" , "Futuristas", "My children"];

corpus.context = ["weird", "anticipatory", "busy", "forgiving", "diseased", "strange", "desperate", "invisible", "borderless", "flooded", "dry", "crowded", "competitive", "open sourced", "cooperative", "collaborative", "depressing", "empowering", "inspiring", "loved", "crowded", "chaotic", "judgmental", "scary", "bedazzled", "dormant", "unstable", "satisfactory", "virtual", "expansive", "isolated", "fun", "inclusive", "hot","challenging", "collaborative", "connected", "highly organized", "sustainable", "wholly unfamiliar", "regulated", "adversarial", "friendly", "community-oriented" ];

corpus.verb = ["laughing", "sharing", "destroying", "running", "being watched", "gathering information", "gardening", "stalking birds", "blogging", "harvesting", "organizing", "eating", "dreaming", "philosophizing", "peacemaking", "rendering", "owning", "speaking", "dancing", "sleeping", "ritualizing", "smelling", "vacationing", "living", "celebrating", "dying", "creating","running", "touching", "tasting", "smelling", "hearing", "seeing", "using telepathy", "designing interactions", "driving", "singing", "blogging","browsing","chatting","file sharing","gaming","hacking","microblogging","sharing","shopping","syncing"];

corpus.adjective = ["healthy", "four dimensional", "audio reactive", "collaborative", "time traveling", "local", "green", "intense", "lab grown", "isolated", "artisinal", "organic", "free range", "family owned", "musical", "resilient", "quality", "implanted", "organic", "compartmentalized", "fresh", "genetically engineered", "composted", "teleported", "nourishing", "sentient", "compressed","cross-platform","crowdsourced","distributed","dynamic","generative","gesture controlled","integrated","lightweight","locally executing","memcached","monetized","motion controlled","open source","optimized","micro", "nano", "swarming", "smart", "emergent", "disruptive", "crowdsourced", "increasingly available", "augmented", "hyper-local", "distributed"];

corpus.noun = ["ticket", "backpack", "kitchen sink", "gestural interface","surveillance camera", "birth control", "set of glasses", "ticket", "backpack", "kitchen sink", "internal music device", "shelf", "health checkup screen", "robot-sourced disco bootie", "beard", "monkey", "tea pot", "space craft", "screw driver", "glue gun", "power tool", "slime", "wand", "skate board", "pen", "scooter", "soil", "tree", "earth", "space", "statistic", "microchip", "building", "fly trap", "time machine", "water bottle", "moon", "internal bionic body part", "cyborg plant", "communication device", "necklace", "submarine", "banana", "hamburger", "toothbrush", "water slide", "snake pit", "farm", "home", "tomato", "phone", "jetpack", "car", "book", "plant", "fork and knife", "set of chopsticks", "hat", "street sign"];
<|endoftext|>


<commit_before>var controllers = angular.module('genericController', []);

controllers.service('sharedProperties', function() {
	var entityDetails = {};

	return {
		getEntityDetails : function() {
			return entityDetails;
		},
		setEntityDetails : function(value) {
			entityDetails = value;
		}
	};
});

controllers.controller('GenericController', [
		'$scope',
		'RestService',
		'$route',
		'$routeParams',
		'$location',
		'sharedProperties',
		function($scope, RestService, $route, $routeParams, $location,
				sharedProperties) {

			/* General variable declarations and functions */

			restEntitiesUrl = $route.current.restEntitiesUrl;
			appEntitiesUrl = $route.current.appEntitiesUrl;

			/* Create */

			$scope.createEntity = function() {
				RestService(restEntitiesUrl).save($scope.entity).$promise.then(
						function(value, headers) {

							console.log(value);

							// Find and Query new entity
							/*console
									.log(RestService(
											value('Location'))
											.query());*/
							// find all under "_links" except "self"

							// Post referenced entity

							// URL for relationship entity
							//console.log($scope.entity.client._links.self.href);
						}, function(error) {
							console.log(error.data);
						});

				$scope.entities = RestService(restEntitiesUrl).query();
				$location.path(appEntitiesUrl);
			};

			/* View Create */

			$scope.viewCreateEntity = function() {
				sharedProperties.setEntityDetails({});
				$location.path(appEntitiesUrl + "-create");
			};

			/* Read all */

			$scope.entities = RestService(restEntitiesUrl).query();

			/* Read One */

			$scope.entity = sharedProperties.getEntityDetails();

			/* View Entity */

			$scope.viewEntity = function(restUrl) {
				sharedProperties.setEntityDetails(RestService(restUrl).get());
				$location.path(appEntitiesUrl + "-detail");
			};

			/* Update */

			$scope.updateEntity = function(restUrl) {
				RestService(restUrl).update($scope.entity);
				sharedProperties.setEntityDetails({});
				$location.path(appEntitiesUrl);
			};

			/* Delete */

			$scope.deleteEntity = function(restUrl) {
				RestService(restUrl).remove();
				$scope.entities = RestService(restEntitiesUrl).query();
				$location.path(appEntitiesUrl);
			};

			/* Cancel */

			$scope.cancel = function() {
				sharedProperties.setEntityDetails({});
				$location.path(appEntitiesUrl);
			};

			/* Categories and Clients */

			$scope.categories = RestService("/categories").query();
			$scope.clients = RestService("/clients").query();

		} ]);
<commit_msg>Remove promise and continue to work on create entity with relationships.<commit_after>var controllers = angular.module('genericController', []);

controllers.service('sharedProperties', function() {
	var entityDetails = {};

	return {
		getEntityDetails : function() {
			return entityDetails;
		},
		setEntityDetails : function(value) {
			entityDetails = value;
		}
	};
});

controllers.controller('GenericController', [
		'$scope',
		'RestService',
		'$route',
		'$routeParams',
		'$location',
		'sharedProperties',
		function($scope, RestService, $route, $routeParams, $location,
				sharedProperties) {

			/* General variable declarations and functions */

			restEntitiesUrl = $route.current.restEntitiesUrl;
			appEntitiesUrl = $route.current.appEntitiesUrl;

			/* Create */

			$scope.createEntity = function() {

				RestService(restEntitiesUrl).save($scope.entity,
						function(data, header) {

							// Find and get new entity
							newEntity = RestService(header('Location')).query();
							console.log(newEntity);

							// find all under "_links" except "self"
							// Post referenced entity
							// URL for relationship entity
							// console.log($scope.entity.client._links.self.href);
						}, function(error) {
							console.log(error.data);
						});

				$scope.entities = RestService(restEntitiesUrl).query();
				$location.path(appEntitiesUrl);
			};

			/* View Create */

			$scope.viewCreateEntity = function() {
				sharedProperties.setEntityDetails({});
				$location.path(appEntitiesUrl + "-create");
			};

			/* Read all */

			$scope.entities = RestService(restEntitiesUrl).query();

			/* Read One */

			$scope.entity = sharedProperties.getEntityDetails();

			/* View Entity */

			$scope.viewEntity = function(restUrl) {
				sharedProperties.setEntityDetails(RestService(restUrl).get());
				$location.path(appEntitiesUrl + "-detail");
			};

			/* Update */

			$scope.updateEntity = function(restUrl) {
				RestService(restUrl).update($scope.entity);
				sharedProperties.setEntityDetails({});
				$location.path(appEntitiesUrl);
			};

			/* Delete */

			$scope.deleteEntity = function(restUrl) {
				RestService(restUrl).remove();
				$scope.entities = RestService(restEntitiesUrl).query();
				$location.path(appEntitiesUrl);
			};

			/* Cancel */

			$scope.cancel = function() {
				sharedProperties.setEntityDetails({});
				$location.path(appEntitiesUrl);
			};

			/* Categories and Clients */

			$scope.categories = RestService("/categories").query();
			$scope.clients = RestService("/clients").query();

		} ]);
<|endoftext|>


<commit_before><commit_msg>Delete custom.js<commit_after><|endoftext|>


<commit_before>angular.module('citizen-engagement.mapCtrl', [])

    .factory('GeolocServiceFla', function (geolocation) {
        var service = {

            locateUser: function () {

                return geolocation.getLocation().then(function (data) {

                    /*$scope.mapCenter.lat = data.coords.latitude;
                     $scope.mapCenter.lng = data.coords.longitude;
                     $scope.mapCenter.zoom = 8;*/

                    /*  $scope.mapCenter = {
                     lat: data.coords.latitude,
                     lng: data.coords.longitude,
                     zoom: 8

                     };*/
                    console.log(data.coords.longitude);
                    console.log(data.coords.latitude);
                    return data.coords;

                }, function (error) {
                    $log.error("Could not get location: " + error);
                    console.log("Could not get location: " + error);
                });

            }
        };

        return service;
    })
    .controller("IssuesMapController", function ($scope, mapboxMapId, mapboxAccessToken, $http, apiUrl, GeolocServiceFla) {
        var mapboxTileLayer = "http://api.tiles.mapbox.com/v4/" + mapboxMapId; //openlayers --> mapbox
        mapboxTileLayer = mapboxTileLayer + "/{z}/{x}/{y}.png?access_token=" + mapboxAccessToken;
        $scope.mapDefaults = {
            tileLayer: mapboxTileLayer
        };

        $scope.mapCenter = {};
// TODO loading while geoloc

        GeolocServiceFla.locateUser().then(function (coords) {
            $scope.mapCenter = {
                lat: coords.latitude,
                lng: coords.longitude,
                zoom: 15

            };
        });

        $scope.mapMarkers = [];

        $http.get(apiUrl + '/issues').success(function (issues) {

            $scope.issues = issues;

            console.log(issues);

            GeolocServiceFla.locateUser().then(function (coords) {
                $scope.mapMarkers.push({

                    lat: coords.latitude,
                    lng: coords.longitude,
                    message: '
{{ issue.description }}
',
                    getMessageScope: function () {
                        var scope = $scope.$new();
                        /*    scope.issue = issue;*/
                        return scope;
                    }
                });
            });

        });

    })

    .controller("IssueMapController", function ($scope, mapboxMapId, mapboxAccessToken, $http, apiUrl, GeolocServiceFla, $stateParams) {
        var mapboxTileLayer = "http://api.tiles.mapbox.com/v4/" + mapboxMapId; //openlayers --> mapbox
        mapboxTileLayer = mapboxTileLayer + "/{z}/{x}/{y}.png?access_token=" + mapboxAccessToken;
        $scope.mapDefaults = {
            tileLayer: mapboxTileLayer
        };
        $scope.mapCenter = {};

        GeolocServiceFla.locateUser().then(function (coords) {

        });

        $scope.mapMarkers = [];
        /*        var issue = IssueService.getIssue();*/

        var id = $stateParams.issueId;
        $http({
            method: 'GET',
            url: apiUrl + '/issues/' + id
        }).success(function (issue) {

            $scope.mapCenter = {
                lat: issue.lat,
                lng: issue.lng,
                zoom: 15

            };
            $scope.issue = issue;
            console.log(issue);
            $scope.mapMarkers.push({
                lat: issue.lat,
                lng: issue.lng,

            });

        });

    })

    .controller("HomeMapController", function ($scope, mapboxMapId, mapboxAccessToken, $http, apiUrl, GeolocServiceFla, $stateParams) {
        var mapboxTileLayer = "http://api.tiles.mapbox.com/v4/" + mapboxMapId; //openlayers --> mapbox
        mapboxTileLayer = mapboxTileLayer + "/{z}/{x}/{y}.png?access_token=" + mapboxAccessToken;
        $scope.mapDefaults = {
            tileLayer: mapboxTileLayer
        };
        $scope.mapCenter = {};

        $scope.mapMarkers = [];

// TODO loading while geoloc

        GeolocServiceFla.locateUser().then(function (coords) {
            $scope.mapCenter = {
                lat: coords.latitude,
                lng: coords.longitude,
                zoom: 15
            };

            $scope.mapMarkers.push({
                lat: coords.latitude,
                lng: coords.longitude,
                message: "You are here"

            });

        });

        /* $http.get(apiUrl + '/issues').success(function (issues) {

         $scope.issues = issues;

         //console.log(issues);

         $scope.mapMarkers.push({
         lat: 46.5,
         lng: 6.6,
         message: '
{{ issue.description }}
',
         getMessageScope: function () {
         var scope = $scope.$new();
         /!*    scope.issue = issue;*!/
         return scope;
         }
         });
         });*/

    })

    .controller("UserIssuesController", function (AuthService, apiUrl) {
        $scope.loadUserInfo = function () {
            console.log("ok all issues");

            userId = AuthService.currentUserId;
            $http.get(apiUrl + '/users/' + userId).success(function (user) {

                $scope.user = user;

                console.log(user);

            });
        }
        $scope.loadUserInfo();

        $scope.countIssues = function () {
            IssueService.findIssuesByUser().then(function (issues) {
                $scope.issues = issues;
                $scope.nbIssues = issues.data.length;

            });
        };
    });
;

<commit_msg>view all by user created - not done<commit_after>angular.module('citizen-engagement.mapCtrl', [])

    .factory('GeolocServiceFla', function (geolocation) {
        var service = {

            locateUser: function () {

                return geolocation.getLocation().then(function (data) {

                    /*$scope.mapCenter.lat = data.coords.latitude;
                     $scope.mapCenter.lng = data.coords.longitude;
                     $scope.mapCenter.zoom = 8;*/

                    /*  $scope.mapCenter = {
                     lat: data.coords.latitude,
                     lng: data.coords.longitude,
                     zoom: 8

                     };*/
                    console.log(data.coords.longitude);
                    console.log(data.coords.latitude);
                    return data.coords;

                }, function (error) {
                    $log.error("Could not get location: " + error);
                    console.log("Could not get location: " + error);
                });

            }
        };

        return service;
    })
    .controller("IssuesMapController", function ($scope, mapboxMapId, mapboxAccessToken, $http, apiUrl, GeolocServiceFla) {
        var mapboxTileLayer = "http://api.tiles.mapbox.com/v4/" + mapboxMapId; //openlayers --> mapbox
        mapboxTileLayer = mapboxTileLayer + "/{z}/{x}/{y}.png?access_token=" + mapboxAccessToken;
        $scope.mapDefaults = {
            tileLayer: mapboxTileLayer
        };

        $scope.mapCenter = {};
// TODO loading while geoloc

        GeolocServiceFla.locateUser().then(function (coords) {
            $scope.mapCenter = {
                lat: coords.latitude,
                lng: coords.longitude,
                zoom: 15

            };
        });

        $scope.mapMarkers = [];

        $http.get(apiUrl + '/issues').success(function (issues) {

            $scope.issues = issues;

            console.log(issues);

            GeolocServiceFla.locateUser().then(function (coords) {
                $scope.mapMarkers.push({

                    lat: coords.latitude,
                    lng: coords.longitude,
                    message: '
{{ issue.description }}
',
                    getMessageScope: function () {
                        var scope = $scope.$new();
                        /*    scope.issue = issue;*/
                        return scope;
                    }
                });
            });

        });

    })

    .controller("IssueMapController", function ($scope, mapboxMapId, mapboxAccessToken, $http, apiUrl, GeolocServiceFla, $stateParams) {
        var mapboxTileLayer = "http://api.tiles.mapbox.com/v4/" + mapboxMapId; //openlayers --> mapbox
        mapboxTileLayer = mapboxTileLayer + "/{z}/{x}/{y}.png?access_token=" + mapboxAccessToken;
        $scope.mapDefaults = {
            tileLayer: mapboxTileLayer
        };
        $scope.mapCenter = {};

        GeolocServiceFla.locateUser().then(function (coords) {

        });

        $scope.mapMarkers = [];
        /*        var issue = IssueService.getIssue();*/

        var id = $stateParams.issueId;
        $http({
            method: 'GET',
            url: apiUrl + '/issues/' + id
        }).success(function (issue) {

            $scope.mapCenter = {
                lat: issue.lat,
                lng: issue.lng,
                zoom: 15

            };
            $scope.issue = issue;
            console.log(issue);
            $scope.mapMarkers.push({
                lat: issue.lat,
                lng: issue.lng,

            });

        });

    })

    .controller("HomeMapController", function ($scope, mapboxMapId, mapboxAccessToken, $http, apiUrl, GeolocServiceFla, $stateParams) {
        var mapboxTileLayer = "http://api.tiles.mapbox.com/v4/" + mapboxMapId; //openlayers --> mapbox
        mapboxTileLayer = mapboxTileLayer + "/{z}/{x}/{y}.png?access_token=" + mapboxAccessToken;
        $scope.mapDefaults = {
            tileLayer: mapboxTileLayer
        };
        $scope.mapCenter = {};

        $scope.mapMarkers = [];

// TODO loading while geoloc

        GeolocServiceFla.locateUser().then(function (coords) {
            $scope.mapCenter = {
                lat: coords.latitude,
                lng: coords.longitude,
                zoom: 15
            };

            $scope.mapMarkers.push({
                lat: coords.latitude,
                lng: coords.longitude,
                message: "You are here"

            });

        });

        /* $http.get(apiUrl + '/issues').success(function (issues) {

         $scope.issues = issues;

         //console.log(issues);

         $scope.mapMarkers.push({
         lat: 46.5,
         lng: 6.6,
         message: '
{{ issue.description }}
',
         getMessageScope: function () {
         var scope = $scope.$new();
         /!*    scope.issue = issue;*!/
         return scope;
         }
         });
         });*/

    })

    .controller("UserIssuesController", function ($scope, $http, AuthService, apiUrl, IssueService) {
        $scope.loadUserInfo = function () {
            console.log("ok all issues");

            userId = AuthService.currentUserId;
            $http.get(apiUrl + '/users/' + userId).success(function (user) {

                $scope.user = user;

                console.log(user);

            });
        }
        $scope.loadUserInfo();

        $scope.getIssuesByUser = function () {
            IssueService.findIssuesByUser().then(function (issues) {
                $scope.issues = issues;
                $scope.nbIssues = issues.data.length;

            });
        }; $scope.getIssuesByUser();
    });
;

<|endoftext|>


<commit_before>import $ from 'jquery'
import 'tablesorter'
import '../css/vacation-overview.css'

$(function () {

    function selectedItemChange() {
      const selectedYear = document.querySelector('#yearSelect');
      const selectedMonth = document.querySelector('#monthSelect');
      const selectedDepartment = document.querySelector('#departmentSelect');
      const selectedDepartmentValue = selectedDepartment.options[selectedDepartment.selectedIndex].text;
      const selectedYearValue = selectedYear.options[selectedYear.selectedIndex].text;
      const selectedMonthValue = selectedMonth.options[selectedMonth.selectedIndex].value;

      function compare(currentDay, currentValue, status, type, dayLength) {
        if (currentDay.dayText === currentValue.date
          && currentValue.status === status
          && currentValue.type === type
          && currentValue.dayLength === dayLength) {
          return true;
        }
      }

      if (selectedYearValue != null && selectedMonthValue != null && selectedDepartmentValue != null) {
        const url = location.protocol + "//" + location.host
          + "/api/vacationoverview?selectedYear="
          + encodeURIComponent(selectedYearValue) + "&selectedMonth="
          + encodeURIComponent(selectedMonthValue) + "&selectedDepartment="
          + encodeURIComponent(selectedDepartmentValue);

        const xhttp = new XMLHttpRequest();
        xhttp.open("GET", url, false);
        xhttp.setRequestHeader("Content-type", "application/json");
        xhttp.send();
        const holyDayOverviewResponse = JSON.parse(xhttp.responseText);
        if (holyDayOverviewResponse && holyDayOverviewResponse.response) {

          const overViewList = holyDayOverviewResponse.response.list;
          overViewList
            .forEach(function (listItem) {
              const personId = listItem.personID;
              const url = location.protocol + "//"
                + location.host + "/api/absences?year="
                + encodeURIComponent(selectedYearValue) + "&month="
                + encodeURIComponent(selectedMonthValue) + "&person="
                + encodeURIComponent(personId);
              const xhttp = new XMLHttpRequest();
              xhttp.open("GET", url, false);
              xhttp.setRequestHeader("Content-type",
                "application/json");
              xhttp.send();

              const response = JSON.parse(xhttp.responseText);
              if (response) {

                listItem.days
                  .forEach(
                    function (currentDay) {
                      let absences = response.response.absences;

                      if (absences.find(currentValue => compare(currentDay, currentValue, "WAITING", "VACATION", 1))) {
                        currentDay.cssClass = 'vacationOverview-day-personal-holiday-status-WAITING vacationOverview-day-item';
                      }

                      if (absences.find(currentValue => compare(currentDay, currentValue, "WAITING", "VACATION", 0.5))) {
                        currentDay.cssClass = 'vacationOverview-day-personal-holiday-half-day-status-WAITING vacationOverview-day-item';
                      }

                      if (absences.find(currentValue => compare(currentDay, currentValue, "ALLOWED", "VACATION", 0.5))) {
                        currentDay.cssClass = 'vacationOverview-day-personal-holiday-half-day-status-ALLOWED vacationOverview-day-item';
                      }

                      if (absences.find(currentValue => compare(currentDay, currentValue, "ALLOWED", "VACATION", 1))) {
                        currentDay.cssClass = 'vacationOverview-day-personal-holiday-status-ALLOWED vacationOverview-day-item';
                      }

                      if (absences.find(currentValue => compare(currentDay, currentValue, "ACTIVE", "SICK_NOTE", 1))) {
                        currentDay.cssClass = 'vacationOverview-day-sick-note vacationOverview-day-item';
                      }

                      if (absences.find(currentValue => compare(currentDay, currentValue, "ACTIVE", "SICK_NOTE", 0.5))) {
                        currentDay.cssClass = 'vacationOverview-day-sick-note-half-day vacationOverview-day-item';
                      }

                    }, this);
              }
            });

          let outputTable = "
";
          outputTable += "
";
          outputTable += "
";
          outputTable += "<spring:message code='person.data.firstName'/>	";
          outputTable += "<spring:message code='person.data.lastName'/>	";
          overViewList[0].days
            .forEach(
              function (item) {
                let defaultClasses = "non-sortable vacationOverview-day-item";
                if (item.typeOfDay === "WEEKEND") {
                  outputTable += "" + item.dayNumber + "	";
                } else {
                  outputTable += "" + item.dayNumber + "	";
                }
              }, outputTable);
          outputTable += "

";
          overViewList
            .forEach(
              function (item) {
                outputTable += "
";
                outputTable += ""
                  + item.person.firstName
                  + "	";
                outputTable += ""
                  + item.person.lastName
                  + "	";
                item.days
                  .forEach(
                    function (dayItem) {
                      if (dayItem.typeOfDay === "WEEKEND") {
                        dayItem.cssClass = ' vacationOverview-day-weekend vacationOverview-day-item';
                      } else {
                        if (!dayItem.cssClass) {
                          dayItem.cssClass = ' vacationOverview-day vacationOverview-day-item ';
                        }
                      }
                      outputTable += "	";
                    }, outputTable);
                outputTable += "
";
              }, outputTable);

          outputTable += "

";
          const element = document.querySelector("#vacationOverview");
          element.innerHTML = outputTable;
        }
      }

      $("table.sortable").tablesorter({
        sortList: [[0, 0]],
        headers: {
          '.non-sortable': {
            sorter: false
          }
        }
      });
    }

    const selectedYear = document.querySelector('#yearSelect');
    const selectedMonth = document.querySelector('#monthSelect');
    const selectedDepartment = document.querySelector('#departmentSelect');

    selectedYear.addEventListener("change", function () {
      selectedItemChange();
    });
    selectedMonth.addEventListener("change", function () {
      selectedItemChange();
    });
    selectedDepartment.addEventListener("change", function () {
      selectedItemChange();
    });

    let event;
    if (typeof (Event) === "function") {
      event = new Event("change");
    } else {
      event = document.createEvent("Event");
      event.initEvent("change", true, true);
    }
    selectedYear.dispatchEvent(event);
  }
);
<commit_msg>cleanup vacation overview: remove cellspacing<commit_after>import $ from 'jquery'
import 'tablesorter'
import '../css/vacation-overview.css'

$(function () {

    function selectedItemChange() {
      const selectedYear = document.querySelector('#yearSelect');
      const selectedMonth = document.querySelector('#monthSelect');
      const selectedDepartment = document.querySelector('#departmentSelect');
      const selectedDepartmentValue = selectedDepartment.options[selectedDepartment.selectedIndex].text;
      const selectedYearValue = selectedYear.options[selectedYear.selectedIndex].text;
      const selectedMonthValue = selectedMonth.options[selectedMonth.selectedIndex].value;

      function compare(currentDay, currentValue, status, type, dayLength) {
        if (currentDay.dayText === currentValue.date
          && currentValue.status === status
          && currentValue.type === type
          && currentValue.dayLength === dayLength) {
          return true;
        }
      }

      if (selectedYearValue != null && selectedMonthValue != null && selectedDepartmentValue != null) {
        const url = location.protocol + "//" + location.host
          + "/api/vacationoverview?selectedYear="
          + encodeURIComponent(selectedYearValue) + "&selectedMonth="
          + encodeURIComponent(selectedMonthValue) + "&selectedDepartment="
          + encodeURIComponent(selectedDepartmentValue);

        const xhttp = new XMLHttpRequest();
        xhttp.open("GET", url, false);
        xhttp.setRequestHeader("Content-type", "application/json");
        xhttp.send();
        const holyDayOverviewResponse = JSON.parse(xhttp.responseText);
        if (holyDayOverviewResponse && holyDayOverviewResponse.response) {

          const overViewList = holyDayOverviewResponse.response.list;
          overViewList
            .forEach(function (listItem) {
              const personId = listItem.personID;
              const url = location.protocol + "//"
                + location.host + "/api/absences?year="
                + encodeURIComponent(selectedYearValue) + "&month="
                + encodeURIComponent(selectedMonthValue) + "&person="
                + encodeURIComponent(personId);
              const xhttp = new XMLHttpRequest();
              xhttp.open("GET", url, false);
              xhttp.setRequestHeader("Content-type",
                "application/json");
              xhttp.send();

              const response = JSON.parse(xhttp.responseText);
              if (response) {

                listItem.days
                  .forEach(
                    function (currentDay) {
                      let absences = response.response.absences;

                      if (absences.find(currentValue => compare(currentDay, currentValue, "WAITING", "VACATION", 1))) {
                        currentDay.cssClass = 'vacationOverview-day-personal-holiday-status-WAITING vacationOverview-day-item';
                      }

                      if (absences.find(currentValue => compare(currentDay, currentValue, "WAITING", "VACATION", 0.5))) {
                        currentDay.cssClass = 'vacationOverview-day-personal-holiday-half-day-status-WAITING vacationOverview-day-item';
                      }

                      if (absences.find(currentValue => compare(currentDay, currentValue, "ALLOWED", "VACATION", 0.5))) {
                        currentDay.cssClass = 'vacationOverview-day-personal-holiday-half-day-status-ALLOWED vacationOverview-day-item';
                      }

                      if (absences.find(currentValue => compare(currentDay, currentValue, "ALLOWED", "VACATION", 1))) {
                        currentDay.cssClass = 'vacationOverview-day-personal-holiday-status-ALLOWED vacationOverview-day-item';
                      }

                      if (absences.find(currentValue => compare(currentDay, currentValue, "ACTIVE", "SICK_NOTE", 1))) {
                        currentDay.cssClass = 'vacationOverview-day-sick-note vacationOverview-day-item';
                      }

                      if (absences.find(currentValue => compare(currentDay, currentValue, "ACTIVE", "SICK_NOTE", 0.5))) {
                        currentDay.cssClass = 'vacationOverview-day-sick-note-half-day vacationOverview-day-item';
                      }

                    }, this);
              }
            });

          let outputTable = "
";
          outputTable += "
";
          outputTable += "
";
          outputTable += "<spring:message code='person.data.firstName'/>	";
          outputTable += "<spring:message code='person.data.lastName'/>	";
          overViewList[0].days
            .forEach(
              function (item) {
                let defaultClasses = "non-sortable vacationOverview-day-item";
                if (item.typeOfDay === "WEEKEND") {
                  outputTable += "" + item.dayNumber + "	";
                } else {
                  outputTable += "" + item.dayNumber + "	";
                }
              }, outputTable);
          outputTable += "

";
          overViewList
            .forEach(
              function (item) {
                outputTable += "
";
                outputTable += ""
                  + item.person.firstName
                  + "	";
                outputTable += ""
                  + item.person.lastName
                  + "	";
                item.days
                  .forEach(
                    function (dayItem) {
                      if (dayItem.typeOfDay === "WEEKEND") {
                        dayItem.cssClass = ' vacationOverview-day-weekend vacationOverview-day-item';
                      } else {
                        if (!dayItem.cssClass) {
                          dayItem.cssClass = ' vacationOverview-day vacationOverview-day-item ';
                        }
                      }
                      outputTable += "	";
                    }, outputTable);
                outputTable += "
";
              }, outputTable);

          outputTable += "

";
          const element = document.querySelector("#vacationOverview");
          element.innerHTML = outputTable;
        }
      }

      $("table.sortable").tablesorter({
        sortList: [[0, 0]],
        headers: {
          '.non-sortable': {
            sorter: false
          }
        }
      });
    }

    const selectedYear = document.querySelector('#yearSelect');
    const selectedMonth = document.querySelector('#monthSelect');
    const selectedDepartment = document.querySelector('#departmentSelect');

    selectedYear.addEventListener("change", function () {
      selectedItemChange();
    });
    selectedMonth.addEventListener("change", function () {
      selectedItemChange();
    });
    selectedDepartment.addEventListener("change", function () {
      selectedItemChange();
    });

    let event;
    if (typeof (Event) === "function") {
      event = new Event("change");
    } else {
      event = document.createEvent("Event");
      event.initEvent("change", true, true);
    }
    selectedYear.dispatchEvent(event);
  }
);
<|endoftext|>


<commit_before>dojo.provide("dijit.layout.TabContainer");

dojo.require("dijit.layout.StackContainer");
dojo.require("dijit._Templated");

dojo.declare(
	"dijit.layout.TabContainer",
	[dijit.layout.StackContainer, dijit._Templated],
{
	// summary
	//	A TabContainer is a container that has multiple panes, but shows only
	//	one pane at a time.  There are a set of tabs corresponding to each pane,
	//	where each tab has the title (aka title) of the pane, and optionally a close button.
	//
	//	Publishes topics <widgetId>-addChild, <widgetId>-removeChild, and <widgetId>-selectChild
	//	(where <widgetId> is the id of the TabContainer itself.

	// tabPosition: String
	//   Defines where tabs go relative to tab content.
	//   "top", "bottom", "left-h", "right-h"
	tabPosition: "top",

	templateString: null,	// override setting in StackContainer
	templatePath: dojo.moduleUrl("dijit.layout", "templates/TabContainer.html"),

	postCreate: function(){
		dijit.layout.TabContainer.superclass.postCreate.apply(this, arguments);
		// create the tab list that will have a tab (a.k.a. tab button) for each tab panel
		this.tablist = new dijit.layout.TabController(
			{
				id: this.id + "_tablist",
				tabPosition: this.tabPosition,
				doLayout: this.doLayout,
				containerId: this.id
			}, this.tablistNode);
	},

	_setupChild: function(tab){
		dojo.addClass(tab.domNode, "dijitTabPane");
		dijit.layout.TabContainer.superclass._setupChild.apply(this, arguments);
		return tab;
	},

	startup: function(){
		// wire up the tablist and its tabs
		this.tablist.startup();
		dijit.layout.TabContainer.superclass.startup.apply(this, arguments);
	},

	layout: function(){
		// Summary: Configure the content pane to take up all the space except for where the tabs are
		if(!this.doLayout){ return; }

		// position and size the titles and the container node
		var titleAlign=this.tabPosition.replace(/-h/,"");
		var children = [
			{domNode: this.tablist.domNode, layoutAlign: titleAlign},
			{domNode: this.containerNode, layoutAlign: "client"}
		];
		dijit.layout.layoutChildren(this.domNode, this._contentBox, children);

		// Compute size to make each of my children.
		// children[1] is the margin-box size of this.containerNode, set by layoutChildren() call above
		this._containerContentBox = dijit.layout.marginBox2contentBox(this.containerNode, children[1]);

		if(this.selectedChildWidget){
			this._showChild(this.selectedChildWidget);
			this.selectedChildWidget.resize(this._containerContentBox);
		}
	},

	destroy: function(){
		this.tablist.destroy();
		dijit.layout.TabContainer.superclass.destroy.apply(this, arguments);
	}
});

//TODO: make private?
dojo.declare(
    "dijit.layout.TabController",
    dijit.layout.StackController,
	{
		// summary
		// 	Set of tabs (the things with titles and a close button, that you click to show a tab panel).
		//	Lets the user select the currently shown pane in a TabContainer or StackContainer.
		//	TabController also monitors the TabContainer, and whenever a pane is
		//	added or deleted updates itself accordingly.

		templateString: "

",

		// tabPosition: String
		//   Defines where tabs go relative to the content.
		//   "top", "bottom", "left-h", "right-h"
		tabPosition: "top",

		doLayout: true,

		// buttonWidget: String
		//	the name of the tab widget to create to correspond to each page
		buttonWidget: "dijit.layout._TabButton",

		postMixInProperties: function(){
			this["class"] = "dijitTabLabels-" + this.tabPosition + (this.doLayout ? "" : " dijitTabNoLayout");
			dijit.layout.TabController.superclass.postMixInProperties.apply(this, arguments);
		}
	}
);

dojo.declare(
	"dijit.layout._TabButton", dijit.layout._StackButton,
{
	// summary
	//	A tab (the thing you click to select a pane).
	//	Contains the title of the pane, and optionally a close-button to destroy the pane.
	//	This is an internal widget and should not be instantiated directly.

	baseClass: "dijitTab",

	templateString: "
"
						+"
"
							+"${!label}"
							+""
								+"x"
							+""
						+"
"
					+"
",

	postCreate: function(){
		if(this.closeButton){
			dojo.addClass(this.innerDiv, "dijitClosable");
		} else {
			this.closeButtonNode.style.display="none";
		}
		dijit.layout._TabButton.superclass.postCreate.apply(this, arguments);
		dojo.setSelectable(this.titleNode, false);
	}
});
<commit_msg>On initial display, check if resize() function exists before calling it, just like when we switch to a new tab.  Refs #3994.<commit_after>dojo.provide("dijit.layout.TabContainer");

dojo.require("dijit.layout.StackContainer");
dojo.require("dijit._Templated");

dojo.declare(
	"dijit.layout.TabContainer",
	[dijit.layout.StackContainer, dijit._Templated],
{
	// summary
	//	A TabContainer is a container that has multiple panes, but shows only
	//	one pane at a time.  There are a set of tabs corresponding to each pane,
	//	where each tab has the title (aka title) of the pane, and optionally a close button.
	//
	//	Publishes topics <widgetId>-addChild, <widgetId>-removeChild, and <widgetId>-selectChild
	//	(where <widgetId> is the id of the TabContainer itself.

	// tabPosition: String
	//   Defines where tabs go relative to tab content.
	//   "top", "bottom", "left-h", "right-h"
	tabPosition: "top",

	templateString: null,	// override setting in StackContainer
	templatePath: dojo.moduleUrl("dijit.layout", "templates/TabContainer.html"),

	postCreate: function(){
		dijit.layout.TabContainer.superclass.postCreate.apply(this, arguments);
		// create the tab list that will have a tab (a.k.a. tab button) for each tab panel
		this.tablist = new dijit.layout.TabController(
			{
				id: this.id + "_tablist",
				tabPosition: this.tabPosition,
				doLayout: this.doLayout,
				containerId: this.id
			}, this.tablistNode);
	},

	_setupChild: function(tab){
		dojo.addClass(tab.domNode, "dijitTabPane");
		dijit.layout.TabContainer.superclass._setupChild.apply(this, arguments);
		return tab;
	},

	startup: function(){
		// wire up the tablist and its tabs
		this.tablist.startup();
		dijit.layout.TabContainer.superclass.startup.apply(this, arguments);
	},

	layout: function(){
		// Summary: Configure the content pane to take up all the space except for where the tabs are
		if(!this.doLayout){ return; }

		// position and size the titles and the container node
		var titleAlign=this.tabPosition.replace(/-h/,"");
		var children = [
			{domNode: this.tablist.domNode, layoutAlign: titleAlign},
			{domNode: this.containerNode, layoutAlign: "client"}
		];
		dijit.layout.layoutChildren(this.domNode, this._contentBox, children);

		// Compute size to make each of my children.
		// children[1] is the margin-box size of this.containerNode, set by layoutChildren() call above
		this._containerContentBox = dijit.layout.marginBox2contentBox(this.containerNode, children[1]);

		if(this.selectedChildWidget){
			this._showChild(this.selectedChildWidget);
			if(this.doLayout && this.selectedChildWidget.resize){
				this.selectedChildWidget.resize(this._containerContentBox);
			}
		}
	},

	destroy: function(){
		this.tablist.destroy();
		dijit.layout.TabContainer.superclass.destroy.apply(this, arguments);
	}
});

//TODO: make private?
dojo.declare(
    "dijit.layout.TabController",
    dijit.layout.StackController,
	{
		// summary
		// 	Set of tabs (the things with titles and a close button, that you click to show a tab panel).
		//	Lets the user select the currently shown pane in a TabContainer or StackContainer.
		//	TabController also monitors the TabContainer, and whenever a pane is
		//	added or deleted updates itself accordingly.

		templateString: "

",

		// tabPosition: String
		//   Defines where tabs go relative to the content.
		//   "top", "bottom", "left-h", "right-h"
		tabPosition: "top",

		doLayout: true,

		// buttonWidget: String
		//	the name of the tab widget to create to correspond to each page
		buttonWidget: "dijit.layout._TabButton",

		postMixInProperties: function(){
			this["class"] = "dijitTabLabels-" + this.tabPosition + (this.doLayout ? "" : " dijitTabNoLayout");
			dijit.layout.TabController.superclass.postMixInProperties.apply(this, arguments);
		}
	}
);

dojo.declare(
	"dijit.layout._TabButton", dijit.layout._StackButton,
{
	// summary
	//	A tab (the thing you click to select a pane).
	//	Contains the title of the pane, and optionally a close-button to destroy the pane.
	//	This is an internal widget and should not be instantiated directly.

	baseClass: "dijitTab",

	templateString: "
"
						+"
"
							+"${!label}"
							+""
								+"x"
							+""
						+"
"
					+"
",

	postCreate: function(){
		if(this.closeButton){
			dojo.addClass(this.innerDiv, "dijitClosable");
		} else {
			this.closeButtonNode.style.display="none";
		}
		dijit.layout._TabButton.superclass.postCreate.apply(this, arguments);
		dojo.setSelectable(this.titleNode, false);
	}
});
<|endoftext|>


<commit_before>import React from 'react';
import {ReverseLink} from 'react-router-reverse';

export default class Search extends React.Component {
  static propTypes = {
    q: React.PropTypes.string,
    results: React.PropTypes.array,
    search: React.PropTypes.func.isRequired,
  };

  constructor(props) {
    super(props);
    this.state = {
      q: null
    };
  }

  handleChange = e => {
    var q = e.target.value;
    this.setState({q});
    this.props.search(q);
  }

  render() {
    return (

        <input className="search-input" name="q" placeholder="Search..."
               type="search" onChange={this.handleChange}
               value={this.state.q}/>
        {this.state.q && this.props.q === this.state.q &&
         !this.props.results.length &&

No results found for "{this.state.q}"

        }

        {this.props.results.length &&

            {this.props.results.map(result =>

                <ReverseLink to="addon-review-detail"
                             params={{slug: result.slug}}>
                  {result.name} ({result.slug})
                </ReverseLink>

            )}

        || ''}

    );
  }
}
<commit_msg>don't show search results if no query<commit_after>import React from 'react';
import {ReverseLink} from 'react-router-reverse';

export default class Search extends React.Component {
  static propTypes = {
    q: React.PropTypes.string,
    results: React.PropTypes.array,
    search: React.PropTypes.func.isRequired,
  };

  constructor(props) {
    super(props);
    this.state = {
      q: null
    };
  }

  handleChange = e => {
    var q = e.target.value;
    this.setState({q});
    this.props.search(q);
  }

  render() {
    return (

        <input className="search-input" name="q" placeholder="Search..."
               type="search" onChange={this.handleChange}
               value={this.state.q}/>
        {this.state.q && this.props.q === this.state.q &&
         !this.props.results.length &&

No results found for "{this.state.q}"

        }

        {this.props.results.length && this.state.q &&

            {this.props.results.map(result =>

                <ReverseLink to="addon-review-detail"
                             params={{slug: result.slug}}>
                  {result.name} ({result.slug})
                </ReverseLink>

            )}

        || ''}

    );
  }
}
<|endoftext|>