Ticket #9509 (assigned defect)

Opened 2 years ago

Last modified 1 year ago

with IE9: chart doesn't resize to web page width

Reported by: falkb Assigned to: ChrisNelson (accepted)
Priority: normal Component: TracJsGanttPlugin
Severity: normal Keywords:
Cc: rjollos Trac Release: 0.12

Description

Automatic resizing to page width works with Firefox but the gannt chart has a fixed size of visible 970 pixels using Internet Explorer 9.0.8112.16421.

Attachments

Change History

11/01/11 10:57:10 changed by falkb

uhm... I use latest svn revision of the plugin which is 10855

11/01/11 15:42:07 changed by rjollos

  • cc set to rjollos.

(follow-up: ↓ 4 ) 01/06/12 08:18:17 changed by falkb

more precise: the chart resizes to the window size only on reload of the page displayed in the browser window, but not on just a resize of the browser window.

(in reply to: ↑ 3 ) 01/06/12 08:21:57 changed by falkb

Replying to falkb:

more precise: the chart resizes to the window size only on reload of the page displayed in the browser window, but not on just a resize of the browser window.

That's the behaviour with Firefox.

Actual problem: With IE, it doesn't resize on reload of the page either

01/06/12 10:20:15 changed by falkb

The following patch fixes a runtime error where g was not defined and that newline after Draw() prevented from really setting the resize handler.

Now the event handler is really called if you resize the browser window! Resizing is sensibly slower now. Though we just get to the next bug, because calling Draw() in the handler function is not enough. Maybe you have an idea what else has to be called? I suspect DrawDependencies() at least as well...

Index: tracjsganttplugin/0.11/tracjsgantt/tracjsgantt.py
===================================================================
--- tracjsganttplugin/0.11/tracjsgantt/tracjsgantt.py	(revision 11112)
+++ tracjsganttplugin/0.11/tracjsgantt/tracjsgantt.py	(working copy)
@@ -174,10 +174,10 @@
         text += 'var t;\n'
         text += 'if (window.addEventListener){\n'
         text += '  window.addEventListener("resize", ' + \
-            'function() { g.Draw();\n }, false);\n'
+            'function() { '+self.GanttID+'.Draw(); }, false);\n'
         text += '} else {\n'
         text += '  window.attachEvent("onresize", ' + \
-            'function() { g.Draw();\n });\n'
+            'function() { '+self.GanttID+'.Draw(); });\n'
         text += '}\n'
         return text

01/06/12 16:56:12 changed by ChrisNelson

(In [11117]) Fix up resize handling. Refs #9509.

I can't test IE behavior easily but this works on FF.

01/06/12 16:56:38 changed by ChrisNelson

  • status changed from new to assigned.

(follow-ups: ↓ 9 ↓ 12 ) 01/06/12 21:50:36 changed by falkb

Cool, FF works pretty well now, reload isn't necessary anymore, resizing the window is enough to make the chart resize. IE still doesn't resize at all and remains with that default size, for both, reload and resize of the browser window. Also after the necessary fix for [11117] (since :

Index: tracjsganttplugin/tracjsgantt/tracjsgantt.py
===================================================================
--- tracjsganttplugin/tracjsgantt/tracjsgantt.py	(revision 11119)
+++ tracjsganttplugin/tracjsgantt/tracjsgantt.py	(working copy)
@@ -183,7 +183,7 @@
             'function() { '+self.GanttID+'.Draw(); '
         if options['showdep']:
             text += self.GanttID+'.DrawDependencies();'
-        text += '}, false);\n'
+        text += '});\n'
         text += '}\n'
         return text

(in reply to: ↑ 8 ) 01/06/12 22:07:43 changed by ChrisNelson

Replying to falkb:

Cool, FF works pretty well now, reload isn't necessary anymore, resizing the window is enough to make the chart resize. IE still doesn't resize at all and remains with that default size, for both, reload and resize of the browser window. Also after the necessary fix for [11117] (since : {{{ #!diff Index: tracjsganttplugin/tracjsgantt/tracjsgantt.py =================================================================== --- tracjsganttplugin/tracjsgantt/tracjsgantt.py (revision 11119) +++ tracjsganttplugin/tracjsgantt/tracjsgantt.py (working copy) @@ -183,7 +183,7 @@ 'function() { '+self.GanttID+'.Draw(); ' if optionsshowdep?: text += self.GanttID+'.DrawDependencies?();' - text += '}, false);\n' + text += '});\n' text += '}\n' return text }}}

I'm confused. Are you saying that I need to remove the false?

01/06/12 22:20:34 changed by falkb

01/06/12 22:22:03 changed by falkb

we need to remove the false but still resizing doesn't work and I don't know why and can't find something on the internet about that :(

(in reply to: ↑ 8 ) 01/06/12 22:27:12 changed by falkb

Replying to falkb:

(since

this was just a copy'n'paste mistake

01/06/12 22:28:15 changed by ChrisNelson

(In [11120]) Remove bad argument to attachEvent. Refs #9509.

01/06/12 22:58:40 changed by falkb

I found http://www.codingforums.com/archive/index.php/t-228036.html where people discuss about that resize handler mess with all those different browsers. In the end it seems to me, for getting it work with IE, the resize handler function needs to get some widths from certain inner objects and set the value to the object which is to be resized... too tired for looking through now...

(follow-up: ↓ 17 ) 01/08/12 00:38:46 changed by falkb

This fixes the chart width in IE for reload and resize, and by using this fix, FF and IE shows equal behaviour now!:

Index: tracjsganttplugin/tracjsgantt/htdocs/jsgantt.js
===================================================================
--- tracjsganttplugin/tracjsgantt/htdocs/jsgantt.js	(revision 11120)
+++ tracjsganttplugin/tracjsgantt/htdocs/jsgantt.js	(working copy)
@@ -1693,6 +1693,8 @@
          {
 	     // 95% of overall window width
 	     width = window.innerWidth * 0.95 + 'px';
+         } else {
+             width = document.documentElement.clientWidth * 0.95 + 'px';
          }
 
 	 vDiv.style.width = width;

P.S.: I still see another problem with resize, I mean the vFormat selection always resets to 'day' after you've resized. One must always click the radiobutton to e.g. 'week' again. Somehow changeFormat() or setFormat() is connected with the onclick handler, only. I can see this problem with both browsers, FF and IE. What to do here now?

01/09/12 14:32:20 changed by ChrisNelson

(In [11133]) Handle width in IE. Refs #9509.

(in reply to: ↑ 15 ; follow-up: ↓ 18 ) 01/18/12 11:18:33 changed by anonymous

Replying to falkb:

P.S.: I still see another problem with resize, I mean the vFormat selection always resets to 'day' after you've resized. One must always click the radiobutton to e.g. 'week' again. Somehow changeFormat() or setFormat() is connected with the onclick handler, only.

This patch fixes it this way:

Index: tracjsganttplugin/0.11/tracjsgantt/tracjsgantt.py
===================================================================
--- tracjsganttplugin/0.11/tracjsgantt/tracjsgantt.py	(revision 11153)
+++ tracjsganttplugin/0.11/tracjsgantt/tracjsgantt.py	(working copy)
@@ -177,13 +177,13 @@
         text += '  window.addEventListener("resize", ' + \
             'function() { ' + self.GanttID+'.Draw(); '
         if options['showdep']:
-            text += self.GanttID+'.DrawDependencies();'
+            text += 'JSGantt.changeFormat("'+defaultFormat+'",'+self.GanttID+');'
         text += '}, false);\n'
         text += '} else {\n'
         text += '  window.attachEvent("onresize", ' + \
             'function() { '+self.GanttID+'.Draw(); '
         if options['showdep']:
-            text += self.GanttID+'.DrawDependencies();'
+            text += 'JSGantt.changeFormat("'+defaultFormat+'",'+self.GanttID+');'
         text += '});\n'
         text += '}\n'
         return text

(Note: changeFormat internally calls DrawDependencies)

If no special radiobutton was clicked before, the chart keeps its format (as set in trac.ini) and doesn't switch to "day" anymore. This should be enough for most of all situations.

=> resolved="fixedforme" :-)

(in reply to: ↑ 17 ) 01/19/12 02:55:22 changed by ChrisNelson

Replying to anonymous:

Replying to falkb:

P.S.: I still see another problem with resize, I mean the vFormat selection always resets to 'day' after you've resized. One must always click the radiobutton to e.g. 'week' again. Somehow changeFormat() or setFormat() is connected with the onclick handler, only.

This patch fixes it this way: ... If no special radiobutton was clicked before, the chart keeps its format (as set in trac.ini) and doesn't switch to "day" anymore. This should be enough for most of all situations. => resolved="fixedforme" :-)

Thanks but I really want to remember the format. I have a general idea how to do that that may even work across reloads of the page.


Add/Change #9509 (with IE9: chart doesn't resize to web page width)




Change Properties
Action