source: timingandestimationplugin/branches/trac1.0-Permissions/timingandestimationplugin/htdocs/ticket.js

Last change on this file was 14061, checked in by Russ Tyndall, 9 years ago

branched for trac1.0

File size: 946 bytes
Line 
1(function(){
2function float_to_hours_minutes(inp){
3  var hours = Number($.trim(inp));
4  if ( isNaN(hours) ) return inp;
5  var whole_hours, mins, str, neg = false;
6  if(hours < 0){
7    neg = true;
8    hours *= -1;
9  }
10  whole_hours = Math.floor(hours);
11  mins = Math.floor((hours - whole_hours) * 60);
12  str = neg ? '-' : '';
13  if ( whole_hours > 0 ) str += whole_hours + 'h';
14  if ( mins > 0 )  str += ' ' + mins + 'm';
15  if( whole_hours == 0 && mins == 0 ) str = '0h';
16  return str;
17}
18
19
20function TandE_ticket_ui_improvements (){
21  var i,s,to_munge = ['#h_estimatedhours + td',
22  '#h_totalhours + td',
23  '.changes .trac-field-hours > em',
24  '.changes .trac-field-totalhours > em',
25  '.changes .trac-field-estimatedhours > em'];
26  for(i=0 ; s= to_munge[i] ; i++){
27    $(s).each(function(){ $(this).text(float_to_hours_minutes($(this).text())); });
28  }
29}
30
31$(document).ready(TandE_ticket_ui_improvements);
32})(); // end of scoping function
33
34
35
36
37
38
39
40
41
42
Note: See TracBrowser for help on using the repository browser.