Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/utilities/page/calendar/calendar.css b/utilities/page/calendar/calendar.css
index 9adae7a..dd1b6de 100644
--- a/utilities/page/calendar/calendar.css
+++ b/utilities/page/calendar/calendar.css
@@ -1,5 +1,12 @@
 /**** CALENDAR ****/
 
+.cal_event {
+	text-overflow: ellipsis; 
+	white-space: nowrap; 
+	overflow: hidden;
+	margin-bottom: 3px;
+}
+
 div.cal_body {
 	margin: 16px;
 	background-color: #DDD;
@@ -62,7 +69,7 @@
 }
 
 .cal_month_headtable {
-	/*table-layout:fixed;*/
+	table-layout:fixed;
 	width: 100%;
 }
 
@@ -83,7 +90,7 @@
 
 table.cal_month_table {
 	border-collapse: collapse;
-	/*table-layout:fixed;*/
+	table-layout:fixed;
 	width: 100%;
 }
 
@@ -138,6 +145,7 @@
 
 table.cal_week_table {
 	border-collapse: collapse;
+	table-layout: fixed;
 	width: 100%;
 }
 
@@ -155,15 +163,3 @@
 	width: 100%;
 	cursor:pointer;
 }
-
-div.cal_event_Public {
-	color: GREEN;
-}
-
-div.cal_event_Private {
-	color: BLUE;
-}
-
-div.cal_event_hover {
-	text-decoration: underline;
-}
diff --git a/utilities/page/calendar/calendar.html b/utilities/page/calendar/calendar.html
index 456566d..11dd3bf 100644
--- a/utilities/page/calendar/calendar.html
+++ b/utilities/page/calendar/calendar.html
@@ -13,6 +13,9 @@
 		<button class="btn btn-small" onclick="erpnext.calendar.refresh('Month')">
 			Month View
 		</button>
+		<button class="btn btn-small" onclick="erpnext.calendar.refresh()">
+			<i class="icon-refresh"></i> Refresh
+		</button>
 	</div>
 	<div class="cal_month_head">
 		<span class="cal_view_title"></span>
diff --git a/utilities/page/calendar/calendar.js b/utilities/page/calendar/calendar.js
index 3d3519b..0f4ff3b 100644
--- a/utilities/page/calendar/calendar.js
+++ b/utilities/page/calendar/calendar.js
@@ -115,8 +115,11 @@
 			this.widgets['Ref Link'].innerHTML = '';
 
 			if(this.ev.ref_type) {
-				$(repl('<span>Reference: <a href="#Form/%(ref_type)s/%(ref_name)s" \
-					onclick="cur_dialog.hide()">%(ref_type)s: %(ref_name)s</a></span>', this.ev))
+				$(repl('<table style="width: 100%;"><tr>\
+					<td style="width: 30%"><b>Reference:</b></td>\
+					<td><a href="#Form/%(ref_type)s/%(ref_name)s" \
+					onclick="cur_dialog.hide()">%(ref_type)s: %(ref_name)s</a></td>\
+				</tr></table>', this.ev))
 						.appendTo(this.widgets['Ref Link'])
 			}
 
@@ -256,32 +259,29 @@
 //------------------------------------------------------
 
 Calendar.CalEvent= function(doc, cal) {
-	this.body = document.createElement('div');
-	this.link = $a(this.body, 'a', '', {}, locals['Event'][doc.name].description || '');
-	this.doc = doc;
 	var me = this;
+	me.doc = doc;
+	
+	this.body = $("<div class='label cal_event'></div>")
+		.html(doc.description)
+		.attr("title", doc.description)
+		.css({"cursor":"pointer"})
+		.attr("data-event", doc.name)
+		.click(function() {
+			var doc = locals["Event"][$(this).attr("data-event")];
+			cal.show_event(doc, me);
+		})
 
-	this.link.onclick = function() {
-		if(me.doc.name) {
-			cal.show_event(me.doc, me);
-		}
+	this.show = function(vu) {
+		me.body
+			.html(me.doc.description)
+			.css({"width": ($(vu.body).width()-10)})
+			.appendTo(vu.body)
+			.removeClass("label-success").removeClass("label-info")
+			.addClass(me.doc.event_type=="Public" ? "label-success" : "label-info")
 	}
 }
 
-Calendar.CalEvent.prototype.show = function(vu) {
-
-	var t = this.doc.event_type;
-	this.my_class = 'cal_event_'+ t;
-	
-	if(this.body.parentNode)
-		this.body.parentNode.removeChild(this.body);
-	vu.body.appendChild(this.body);
-	
-	// refresh
-	this.link.innerHTML = this.doc.description || '';
-	this.body.className = this.my_class;
-}
-
 
 // ----------
 
@@ -295,10 +295,13 @@
 
 
 Calendar.View.prototype.show=function() { 
-	this.get_events(); this.refresh(); this.body.style.display = 'block'; 
+	this.body.style.display = 'block';
+	this.get_events(); this.refresh();  
 }
 
-Calendar.View.prototype.hide=function() { this.body.style.display = 'none';}
+Calendar.View.prototype.hide=function() { 
+	this.body.style.display = 'none';
+}
 
 Calendar.View.prototype.next = function() {
 	var s = this.cal.selected_date;
@@ -349,7 +352,8 @@
 	var r = this.headtable.insertRow(0);
 	for(var j=0;j<7;j++) {
  		var cell = r.insertCell(j);
-		cell.innerHTML = erpnext.calendar.weekdays[j]; $w(cell, (100 / 7) + '%');
+		cell.innerHTML = erpnext.calendar.weekdays[j]; 
+		$w(cell, (100 / 7) + '%');
  	}
 
 	this.main = $a(this.body, 'div', 'cal_month_body');
@@ -480,7 +484,6 @@
 	var r = this.headtable.insertRow(0);
 	for(var j=0;j<8;j++) {
  		var cell = r.insertCell(j);
-		$w(cell, (100 / 8) + '%');
  	}
  	
  	// hour header
@@ -652,14 +655,24 @@
 Calendar.ViewUnit.prototype.setevent=function() { }
 
 Calendar.MonthViewUnit=function(parent) {
-	this.header = $a(parent, 'div' , "cal_month_date");
-	this.default_class = "cal_month_unit";
-	
+	var me = this;
+	this.header = $("<div class='cal_month_date'></div>")
+		.appendTo(parent)
+		.css({"cursor":"pointer"})
+		.click(function() {
+			me.body.onclick();
+		})
+		.bind("dblclick", function() {
+			me.body.ondblclick();
+		})
+		.get(0);
+
+	this.default_class = "cal_month_unit";	
 	this.init(parent);
 
 	this.onrefresh = function() {
 		this.header.innerHTML = this.day.getDate();
-	} 
+	}
 }
 Calendar.MonthViewUnit.prototype = new Calendar.ViewUnit();
 Calendar.MonthViewUnit.prototype.is_selected = function() {