← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/reveal-bug into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/reveal-bug into lp:maas.

Commit message:
Fix computation of height in reveal.js (take margin and padding into account).

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1092288 in MAAS: "Commissioning scripts display is truncated"
  https://bugs.launchpad.net/maas/+bug/1092288

For more details, see:
https://code.launchpad.net/~rvb/maas/reveal-bug/+merge/140860

The reveal.js module was computing the height of the 'revealed' panel incorrectly, not taking into account the padding and the margin.  This branch fixes that.

Here is how it looks with that fix: http://people.canonical.com/~rvb/new_com_scripts_view.png.


-- 
https://code.launchpad.net/~rvb/maas/reveal-bug/+merge/140860
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/reveal-bug into lp:maas.
=== modified file 'src/maasserver/static/js/reveal.js'
--- src/maasserver/static/js/reveal.js	2012-12-04 01:43:12 +0000
+++ src/maasserver/static/js/reveal.js	2012-12-20 10:54:22 +0000
@@ -85,10 +85,18 @@
  * @method _create_slide_out
  */
 module._create_slide_out = function(node, publisher) {
+    var content_node = node.one('.content');
+    var height = parseInt(content_node.getStyle('height'));
+    var padding_top = parseInt(content_node.getStyle('paddingTop'));
+    var padding_bottom = parseInt(content_node.getStyle('paddingBottom'));
+    var margin_top = parseInt(content_node.getStyle('marginTop'));
+    var margin_bottom = parseInt(content_node.getStyle('marginBottom'));
+    var new_height = (
+	height + padding_top + padding_bottom + margin_top + margin_bottom);
     var anim = new Y.Anim({
         node: node,
         duration: 0.2,
-        to: {height: parseInt(node.one('.content').getStyle('height'))}
+        to: {height: new_height}
     });
     anim.on('end', function () {
         publisher.fire('revealed');

=== modified file 'src/maasserver/static/js/tests/test_reveal.js'
--- src/maasserver/static/js/tests/test_reveal.js	2012-12-02 16:44:19 +0000
+++ src/maasserver/static/js/tests/test_reveal.js	2012-12-20 10:54:22 +0000
@@ -24,6 +24,12 @@
     },
 
     test_slides_out: function() {
+        var original_height = (
+            parseInt(Y.one('.panel .content').getStyle('height')) +
+            parseInt(Y.one('.panel .content').getStyle('marginTop')) +
+            parseInt(Y.one('.panel .content').getStyle('marginBottom')) +
+            parseInt(Y.one('.panel .content').getStyle('paddingTop')) +
+            parseInt(Y.one('.panel .content').getStyle('paddingBottom')));
         Y.one('.panel').setStyle('height', '0');
         Y.one('.link').set('text', 'View log');
         Y.Assert.areEqual('View log', Y.one('.link').get('text'));
@@ -36,6 +42,11 @@
                     parseInt(Y.one('.panel').getStyle('height')) > 0, 
                     'The panel should be revealed'
                     );
+                Y.Assert.areEqual(
+                    original_height,
+                    parseInt(Y.one('.panel').getStyle('height')), 
+                    'The panel has not been resized properly'
+                    );
                 Y.Assert.areEqual('Hide log', Y.one('.link').get('text'));
             });
         });