1. Benoît Allard
  2. buildbot-js

Commits

ben...@benoit.arnhem.aet  committed 84e6af1 Draft

Improve dynamic styling

  • Participants
  • Parent commits b97ac06
  • Branches default

Comments (0)

Files changed (2)

File app.js

View file
     }.property('content.@each'),
     columnCount: function(){
         var numBuilders = this.get('content').length;
-        console.log(numBuilders);
-        gcd = function (a, b) {
-            return (b == 0) ? a : gcd (b, a%b);
-        }
         var w = $(window).width();
         var h = $(window).height();
-        var r = gcd (Math.round(w/10), Math.round(h/10));
-        console.log(Math.round((numBuilders * r)/h));
-        return Math.round((numBuilders * r)/h);
-    }.property('content'),
+        return "-webkit-column-count:"+Math.round(Math.round(w / Math.sqrt((w*h)/numBuilders)));
+    }.property('content.@each'),
 });

File index.html

View file
 
 <script type="text/x-handlebars" data-template-name="builders" >
 {{controller.busyCount}} busy builders at the moment.
-<div {{bindAttr style="-webkit-column-count:{{controller.columnCount}}"}}>
+<div {{bindAttr style="controller.columnCount"}} class="array">
   {{#each controller}}
     <div {{bindAttr class="state"}} style="border: 1px solid black">{{name}}{{#unless isIdle}}(BUSY){{/unless}}</div>
   {{/each}}