##// END OF EJS Templates
tooltips added on Gantt chart to view the details of the issues...
Jean-Philippe Lang -
r157:f35194e6046e
parent child
Show More
@@ -0,0 +1,120
1 <attach event="ondocumentready" handler="parseStylesheets" />
2 <script>
3 /**
4 * Whatever:hover - V1.42.060206 - hover & active
5 * ------------------------------------------------------------
6 * (c) 2005 - Peter Nederlof
7 * Peterned - http://www.xs4all.nl/~peterned/
8 * License - http://creativecommons.org/licenses/LGPL/2.1/
9 *
10 * Whatever:hover is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * Whatever:hover is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * Credits and thanks to:
21 * Arnoud Berendsen, Martin Reurings, Robert Hanson
22 *
23 * howto: body { behavior:url("csshover.htc"); }
24 * ------------------------------------------------------------
25 */
26
27 var csshoverReg = /(^|\s)(([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active)/i,
28 currentSheet, doc = window.document, hoverEvents = [], activators = {
29 onhover:{on:'onmouseover', off:'onmouseout'},
30 onactive:{on:'onmousedown', off:'onmouseup'}
31 }
32
33 function parseStylesheets() {
34 if(!/MSIE (5|6)/.test(navigator.userAgent)) return;
35 window.attachEvent('onunload', unhookHoverEvents);
36 var sheets = doc.styleSheets, l = sheets.length;
37 for(var i=0; i<l; i++)
38 parseStylesheet(sheets[i]);
39 }
40 function parseStylesheet(sheet) {
41 if(sheet.imports) {
42 try {
43 var imports = sheet.imports, l = imports.length;
44 for(var i=0; i<l; i++) parseStylesheet(sheet.imports[i]);
45 } catch(securityException){}
46 }
47
48 try {
49 var rules = (currentSheet = sheet).rules, l = rules.length;
50 for(var j=0; j<l; j++) parseCSSRule(rules[j]);
51 } catch(securityException){}
52 }
53
54 function parseCSSRule(rule) {
55 var select = rule.selectorText, style = rule.style.cssText;
56 if(!csshoverReg.test(select) || !style) return;
57
58 var pseudo = select.replace(/[^:]+:([a-z-]+).*/i, 'on$1');
59 var newSelect = select.replace(/(\.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi, '.$2' + pseudo);
60 var className = (/\.([a-z0-9_-]*on(hover|active))/i).exec(newSelect)[1];
61 var affected = select.replace(/:(hover|active).*$/, '');
62 var elements = getElementsBySelect(affected);
63 if(elements.length == 0) return;
64
65 currentSheet.addRule(newSelect, style);
66 for(var i=0; i<elements.length; i++)
67 new HoverElement(elements[i], className, activators[pseudo]);
68 }
69
70 function HoverElement(node, className, events) {
71 if(!node.hovers) node.hovers = {};
72 if(node.hovers[className]) return;
73 node.hovers[className] = true;
74 hookHoverEvent(node, events.on, function() { node.className += ' ' + className; });
75 hookHoverEvent(node, events.off, function() { node.className = node.className.replace(new RegExp('\\s+'+className, 'g'),''); });
76 }
77 function hookHoverEvent(node, type, handler) {
78 node.attachEvent(type, handler);
79 hoverEvents[hoverEvents.length] = {
80 node:node, type:type, handler:handler
81 };
82 }
83
84 function unhookHoverEvents() {
85 for(var e,i=0; i<hoverEvents.length; i++) {
86 e = hoverEvents[i];
87 e.node.detachEvent(e.type, e.handler);
88 }
89 }
90
91 function getElementsBySelect(rule) {
92 var parts, nodes = [doc];
93 parts = rule.split(' ');
94 for(var i=0; i<parts.length; i++) {
95 nodes = getSelectedNodes(parts[i], nodes);
96 } return nodes;
97 }
98 function getSelectedNodes(select, elements) {
99 var result, node, nodes = [];
100 var identify = (/\#([a-z0-9_-]+)/i).exec(select);
101 if(identify) {
102 var element = doc.getElementById(identify[1]);
103 return element? [element]:nodes;
104 }
105
106 var classname = (/\.([a-z0-9_-]+)/i).exec(select);
107 var tagName = select.replace(/(\.|\#|\:)[a-z0-9_-]+/i, '');
108 var classReg = classname? new RegExp('\\b' + classname[1] + '\\b'):false;
109 for(var i=0; i<elements.length; i++) {
110 result = tagName? elements[i].all.tags(tagName):elements[i].all;
111 for(var j=0; j<result.length; j++) {
112 node = result[j];
113 if(classReg && !classReg.test(node.className)) continue;
114 nodes[nodes.length] = node;
115 }
116 }
117
118 return nodes;
119 }
120 </script> No newline at end of file
@@ -485,7 +485,7 class ProjectsController < ApplicationController
485 485
486 486 @date_from = Date.civil(@year_from, @month_from, 1)
487 487 @date_to = (@date_from >> @months) - 1
488 @issues = @project.issues.find(:all, :order => "start_date, due_date", :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null)", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to])
488 @issues = @project.issues.find(:all, :order => "start_date, due_date", :include => [:tracker, :status, :author, :priority], :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null)", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to])
489 489
490 490 if params[:output]=='pdf'
491 491 @options_for_rfpdf ||= {}
@@ -5,6 +5,11
5 5 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6 6 <meta name="description" content="redMine" />
7 7 <meta name="keywords" content="issue,bug,tracker" />
8 <!--[if IE]>
9 <style type="text/css">
10 body {behavior: url(<%= stylesheet_path "csshover.htc" %>);}
11 </style>
12 <![endif]-->
8 13 <%= stylesheet_link_tag "application" %>
9 14 <%= stylesheet_link_tag "print", :media => "print" %>
10 15 <%= javascript_include_tag :defaults %>
@@ -55,7 +55,7 if @zoom >1
55 55 end
56 56
57 57 g_width = (@date_to - @date_from + 1)*zoom
58 g_height = [(20 * @issues.length + 6), 206].max
58 g_height = [(20 * @issues.length + 6)+150, 206].max
59 59 t_height = g_height + headers_heigth
60 60 %>
61 61
@@ -65,14 +65,14 t_height = g_height + headers_heigth
65 65
66 66 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
67 67 <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_heigth %>px;background: #eee;" class="gantt_hdr"></div>
68 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;" class="gantt_hdr"></div>
68 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
69 69 <%
70 70 #
71 71 # Tasks subjects
72 72 #
73 73 top = headers_heigth + 8
74 74 @issues.each do |i| %>
75 <div style="position: absolute;line-height:1em;height:16px;top:<%= top %>px;left:4px;width:<%= subject_width - 5 %>px;overflow:hidden;">
75 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;">
76 76 <small><%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>:
77 77 <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small>
78 78 </div>
@@ -82,7 +82,7 end %>
82 82 </td>
83 83 <td>
84 84
85 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width %>;overflow:auto;">
85 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
86 86 <div style="width:<%= g_width-1 %>px;height:<%= headers_heigth %>px;background: #eee;" class="gantt_hdr">&nbsp;</div>
87 87 <%
88 88 #
@@ -167,7 +167,7 if Date.today >= @date_from and Date.today <= @date_to %>
167 167 #
168 168 # Tasks
169 169 #
170 top = headers_heigth + 12
170 top = headers_heigth + 10
171 171 @issues.each do |i| %>
172 172 <%
173 173 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
@@ -195,6 +195,15 top = headers_heigth + 12
195 195 <%= i.status.name %>
196 196 <%= (i.done_ratio).to_i %>%
197 197 </div>
198 <% # === tooltip === %>
199 <div style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;" class="tooltip"><span class="tip">
200 <strong><%= "#{i.tracker.name} ##{i.id}" %></strong>: <%=h i.subject %><br />
201 <br />
202 <strong><%= l(:field_start_date) %></strong>: <%= format_date(i.start_date) %><br />
203 <strong><%= l(:field_due_date) %></strong>: <%= format_date(i.due_date) %><br />
204 <strong><%= l(:field_assigned_to) %></strong>: <%= i.assigned_to ? i.assigned_to.name : "-" %><br />
205 <strong><%=l(:field_priority)%></strong>: <%= i.priority.name %>
206 </span></div>
198 207 <% top = top + 20
199 208 end %>
200 209 </div>
@@ -548,7 +548,6 font-size: 1em;
548 548 height:8px;
549 549 font-size:0.8em;
550 550 color:#888;
551 background:#aaa;
552 551 padding:0;
553 552 margin:0;
554 553 line-height:0.8em;
@@ -558,6 +557,22 font-size: 1em;
558 557 .task_done { background:#66f url(../images/task_done.png); border: 1px solid #66f; }
559 558 .task_todo { background:#aaa url(../images/task_todo.png); border: 1px solid #aaa; }
560 559
560 /***** Tooltips ******/
561 .tooltip{position:absolute;z-index:24;}
562 .tooltip:hover{z-index:25;color:#000;}
563 .tooltip span.tip{display: none}
564
565 div.tooltip:hover span.tip{
566 display:block;
567 position:absolute;
568 top:12px; left:20px; width:270px;
569 border:1px solid #555;
570 background-color:#fff;
571 padding: 4px;
572 font-size: 0.8em;
573 color:#505050;
574 }
575
561 576 /***** CSS FORM ******/
562 577 .tabular p{
563 578 margin: 0;
General Comments 0
You need to be logged in to leave comments. Login now