Commits

Seph Soliman committed 59a0021 Merge

Automated merge with ssh://hg@bitbucket.org/seph/basecamp-time-widget

Comments (0)

Files changed (9)

src/css/widget.css

 body { background: transparent; font: 13px 'Lucida Grande'; color: #fff; width: 289px; height: 326px; }
 h2 { font-size: 15px; font-family: 'Lucida Grande'; padding: 6px 0px 0px }
 
-#info { position: absolute; right: 35px; top: 25px; cursor: default; }
+#info { position: absolute; right: 45px; top: 25px; cursor: default; }
 #done { position: absolute; left: 25px; bottom: 48px; cursor: default; }
 .loadindicator { position: absolute; right: 18px; top: 18px; cursor: default; }
 .widgetside { position: relative; width: 289px; height: 326px; }
 .widgetside .widgetcontent { padding: 20px 20px; height: 310px; position: relative; }
 
 #front { background: transparent url('../images/bg-front-collapsed.png') no-repeat 0px 0px; }
+#front.expanding { background: transparent url('../images/bg-front-collapsed-sliding.png') no-repeat 0px 0px; }
 #front.expanded { background-image: url('../images/bg-front.png'); }
 #back { background: transparent url('../images/bg-back.png') no-repeat 0px 0px; }
 
 #back p { margin: 0px 0px 10px; }
 #loginbtn { float: right; }
 
-#show_project { text-decoration: none; font-size: 9px; color: #000; position: absolute; right: 25px; top: 7px;  }
-#show_project:hover { color: #666; }
 #watch { background: transparent url('../images/watch.png') no-repeat center center; width: 56px; height: 63px; right: 25px; top: 40px; position: absolute; }
 
 input[type=text].error { background: #fcc; }
 #time_container #time { float: left; }
 #time_container input[type=button] { float: right; margin-left: 5px; vertical-align: middle; margin-top: 1px; }
 
-#reportcontainer { position: absolute; top: 155px; left: 20px; width: 250px; }
-#reporthours { width: 30px; font-size: 11px; margin-left: 5px; }
-#reportdescription { width: 195px; font-size: 11px; margin-top: 3px; }
-#reportdate { margin: 3px 0px 0px; }
-#reportdate_toggle { font-size: 9px; margin: 3px 0px 0px; cursor: pointer; }
+#reportcontainerbutton { font-size: 9px; position: absolute; top: 110px; left: 130px; color: #fff; text-decoration: none; background: transparent url('../images/down-arrow.png') no-repeat right 4px; padding-right: 10px; }
+#show_project { font-size: 9px; position: absolute; top: 110px; left: 25px; color: #fff; text-decoration: none;  }
+
+#reportcontainer { position: absolute; top: 128px; left: -2px; width: 265px; padding-left: 22px; height: 27px; }
+#reportcontainer.sliding { background: transparent url('../images/slide-bottom.png') no-repeat 2px bottom; overflow: hidden; }
+#reportcontainer div:first-child { margin: 0px 0px 15px; position: absolute; bottom: 0px; width: 248px; }
+#reporthours { width: 30px; font-size: 11px; margin: 0px 5px; }
+#reporttime { position: absolute; left: 0px; top: 0px; height: 25px; }
+#reportdescription { width: 179px; font-size: 11px; margin-top: 5px; }
+#reportdate_toggle { cursor: pointer; display: inline; color: #ccc; }
+#reportdate_toggle:hover { color: #fff; }
+#reportdate { position: absolute; right: 0px; top: 0px; }
+#reportdate #reportdate_y { display: none; }
 #todolist { height: 70px; overflow: auto; width: 200px; }
-#todos { width: 248px; }
+#todos { width: 248px; margin-top: 30px; }
+#reportbtn { position: absolute; top: 56px; right: 0px; }
 
-#reportbtn { position: absolute; top: 65px; right: 0px; }
+input[disabled] { opacity: .4; }
+input[type=text].fieldHelp { color: #999; }
 
-#reportcontainerbutton { font-size: 9px; position: absolute; top: 129px; left: 0px; width: 100%; text-align: center;  }
-#reportcontainerbutton a { color: #fff; text-decoration: none; }
-

src/images/ajax-loader.gif

Old
Old image
New
New image

src/images/bg-front-collapsed-sliding.png

Added
New image

src/images/bg-front.png

Old
Old image
New
New image

src/images/down-arrow.png

Added
New image

src/images/slide-bottom.png

Added
New image

src/js/jquery.helptext.js

+/*
+ * jQuery Helptext plugin 1.0
+ *
+ * http://www.konstellation.dk/blog/2009/04/inline-helptext-med-jquery/
+ *
+ * Copyright (c) 2009 Seph Soliman
+ *
+ * Plugin released under BSD License:
+ *   http://creativecommons.org/licenses/BSD/
+ */
+ 
+jQuery.fn.helptexts = function(textmap) {
+	function enterHelpField() {
+		var field = this;
+		if($(field).hasClass("fieldHelp")) {
+			$(field).removeClass("fieldHelp");
+			field.value = '';
+			field.maxlength = field.oldmaxlength; // * re-set the old limit
+			//$(field).unbind("blur");
+		}
+	}
+	function exitHelpField() {
+		var field = this;
+		if(field.value == '' || field.value == field.helptext) {
+			$(field).addClass("fieldHelp");
+			field.maxlength = field.oldmaxlength; // * no limit for help text
+			field.value = field.helptext;
+		}
+	}
+	
+	function removeHelpTexts(form){
+		$(form).find("input[helptext]").each(function() {
+			if(this.value == this.helptext)
+				this.value = '';
+		});
+	}
+	
+	this.each(function(){
+		jQuery(this).submit(function() { removeHelpTexts(this) });
+		
+		for(var name in textmap) {
+			var helptext = textmap[name];
+			jQuery(this).find("input[name="+name+"], textarea[name="+name+"]").each(function() {
+				this.helptext = helptext;
+				this.oldmaxlength = jQuery(this).attr("maxlength");
+				jQuery(this).focus(enterHelpField);
+				jQuery(this).blur(exitHelpField);
+				jQuery(this).blur();
+			});
+		}
+	});
+};
+
 	$("#projects").change(changeProject);
 	$("#login_form").submit(submitLogin);
 	$("#starttime").click(startTimer);
-	$("#stoptime").click(stopTimer).attr("disabled", true);
+	$("#stoptime").click(stopTimer).attr("disabled", 'disabled');
 	$("#reportbtn").click(reportTime);
 	$("#reporthours").change(function(e) { changeTime() });
 	$("#reporthours").keydown(keyDownTime);
 	$("#roundtime").change(changeRoundTime);
 	$("#show_project").click(openProjectURL);
-	$("#reportdate_toggle").click(function() { $("#reportdate").fadeToggle(200) });
+	$("#reportdate_toggle").toggle(function() {
+		$('span:first', this).fadeIn(200);
+		$('span:last', this).fadeOut(250);
+		$("#reportdate").fadeIn(200)
+	}, function() {
+		$('span:first', this).fadeOut(250);
+		$('span:last', this).fadeIn(200);
+		$("#reportdate").fadeOut(200)
+	});
 	$("#reportcontainerbutton").toggle(function() {
-		$("#front").addClass("expanded");
-		$("#reportcontainer").show(); 
+		$("#front").addClass("expanding");
+		$("#reportcontainer").addClass('sliding').animate({ height: '+=94px' }, 250, 'swing', function() {
+			$("#front").removeClass("expanding");
+			$("#front").addClass("expanded");
+			$(this).removeClass('sliding').show();
+		});
 	}, function() {
-		$("#front").removeClass("expanded");
-		$("#reportcontainer").hide(); 
+		$("#front").addClass("expanding").removeClass('expanded');
+		$("#reportcontainer").addClass('sliding').animate({ height: '-=94px' }, 250, 'swing', function() {
+			$("#front").removeClass("expanding");
+			$("#front").removeClass("expanded");
+			$(this).removeClass('sliding').hide();
+		});
+	});
+	$("#reportcontainer").helptexts({
+		description: 'No comment'
 	});
 	// }}}
 }
 	allCompanies = {};
 	$(projectsNode).find("projects > project").each(function(i) {
 		var t = $(this);
-		
-		var id = t.find("> id").text();
-		var name = t.find("> name").text();
-		var prj = new Project(id, name);
-		
-		var c_id = t.find("> company > id").text();
-		var c_name = t.find("> company > name").text();
-		var cmp = new Company(c_id, c_name);
-		
-		prj.company = cmp;
-		
-		allProjects[prj.id] = prj;
-		allCompanies[cmp.id] = cmp;
+		if(t.find("> status").text() == 'active') {
+			var id = t.find("> id").text();
+			var name = t.find("> name").text();
+			var prj = new Project(id, name);
+			
+			var c_id = t.find("> company > id").text();
+			var c_name = t.find("> company > name").text();
+			var cmp = new Company(c_id, c_name);
+			
+			prj.company = cmp;
+			
+			allProjects[prj.id] = prj;
+			allCompanies[cmp.id] = cmp;
+		}
 	});
 	
 	// * setup the drop down
 	
 	if(prj != null) {
 		var todolists = prj.todolists;
-		$("#todos").html('<option value="">- Select To-Do -</option>');
+		$("#todos").html('<option value="">Select a to-do &raquo;</option>');
 		for(var i in todolists) {
 			var list = todolists[i];
 			// * ignore complete lists
 	var projectId = $("#projects").val();
 	var prj = allProjects[projectId];
 	
-	$("#reportcontainer").hide();
 	$("#show_project").hide();
 	if(prj != null) {
 		if(len(prj.todolists) > 0) {
 		} else {
 			pullProjectTodoLists(prj.id);
 		}
-		$("#reportcontainer").show();
 		$("#show_project").show();
 	}
 }
 function startTimer() {
 	globalTimer.start();
 	//$("#watch").shake(20, 5, 5);
-	$("#starttime").attr("disabled", true).hide();
-	$("#stoptime").attr("disabled", false).show();
-	$("#reporthours").attr("disabled", true);
+	$("#starttime").attr("disabled", 'disabled').hide();
+	$("#stoptime").attr("disabled", '').show();
+	$("#reporthours").attr("disabled", 'disabled');
+	
+	// Reset report date to today and forth on
+	var today = new Date();
+	$("#reportdate_d").val(today.getDate());
+	$("#reportdate_m").val(today.getMonth());
+	$("#reportdate_y").val(today.getFullYear());
 }
 
 function stopTimer() {
 	}
 	globalTimer.stop();
 	//$("#watch").shake(20, 5, 5);
-	$("#starttime").attr("disabled", false).show();
-	$("#stoptime").attr("disabled", true).hide();
-	$("#reporthours").attr("disabled", false);
+	$("#starttime").attr("disabled", '').show();
+	$("#stoptime").attr("disabled", 'disabled').hide();
+	$("#reporthours").attr("disabled", '');
 }
 
 function updateTimer() {
 		<script type='text/javascript' src='/System/Library/WidgetResources/AppleClasses/AppleButton.js' charset='utf-8'></script>
 		<script type='text/javascript' src='js/jquery.js' charset='utf-8'></script>
 		<script type='text/javascript' src='js/jquery.color.js' charset='utf-8'></script>
+		<script type='text/javascript' src='js/jquery.helptext.js' charset='utf-8'></script>
 		<script type='text/javascript' src='js/stopwatch.js' charset='utf-8'></script>
 		<script type='text/javascript' src='js/utils.js' charset='utf-8'></script>
 		<script type='text/javascript' src='js/bc_user.js' charset='utf-8'></script>
 				
 				<div id="projects_container">
 					<select id="projects"><option disabled="disabled" value="">Select a project &raquo;</option><option disabled="disabled" value="">Login to obtain project list</option></select>
-					<a href="#" id="show_project">(open)</a>
 				</div>
 				
+				<a href="#" id="show_project">Open Basecamp</a>
+				<a id="reportcontainerbutton" href="#">Report</a>
+				
 				<div id="time_container">
 					<span id="time">00:00:00</span>
 					<input type="button" value="Start" id="starttime" />
 					<input type="button" value="Stop" id="stoptime" style="display:none" />
 				</div>
 				
-				<div id="reportcontainerbutton">
-					<a href="#">Report &raquo;</a>
-				</div>
-				
 				<div id="reportcontainer">
 					<div>
-						<select id="todos"><option disabled="disabled" value="">Select a todo &raquo;</option></select><br/>
-						<input type="text" value="Description" id="reportdescription" /><input type="text" value="0,0" id="reporthours" /><br/>
-						<div id="reportdate_toggle">· change date</div>
+						<div id="reporttime">
+							<span>Time:<input type="text" value="0,0" id="reporthours" /> hours</span>
+							<div id="reportdate_toggle"><span style="display:none">&laquo;</span><span>today</span></div>
+						</div>
+						<select id="todos"><option disabled="disabled" value="">Select a to-do &raquo;</option></select><br/>
+						<input type="text" value="" id="reportdescription" name="description" /><br/>
 						<div id="reportdate"><select id="reportdate_m"><option/></select><select id="reportdate_d"><option/></select><select id="reportdate_y"><option/></select></div>
 						<input type="button" id="reportbtn" value="Report" /><br/>
 					</div>