Skip to content

Instantly share code, notes, and snippets.

@mixonic
Forked from bricker/template.html
Last active December 21, 2015 03:59
Show Gist options
  • Select an option

  • Save mixonic/6246467 to your computer and use it in GitHub Desktop.

Select an option

Save mixonic/6246467 to your computer and use it in GitHub Desktop.

Revisions

  1. mixonic revised this gist Aug 16, 2013. 2 changed files with 11 additions and 10 deletions.
    4 changes: 2 additions & 2 deletions template.html
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <script type="text/x-handlebars" id="articles">
    {{#each controller}}
    <figure class="img-wrapper" {{bindAttr style="view.imgWrapperStyle"}}>
    {{#each controller itemController="article"}}
    <figure class="img-wrapper" {{bindAttr style="imgWrapperStyle"}}>
    </figure>
    {{/each}}
    </script>
    17 changes: 9 additions & 8 deletions view.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,9 @@
    Kpcc.ArticlesView = Ember.View.extend({
    imgWrapperStyle: function() {
    if(!this.content.get('assets.length')) return "";
    var url;
    url = this.content.get('assets.firstObject.small.url');
    return "background:url("+url+") no-repeat;background-size:cover;";
    }.property('content.assets')
    });
    Kpcc.ArticleController = Ember.ObjectController.extend({
    imgWrapperStyle: function(){
    var assets = this.get('assets');
    if (!assets.get('length'))
    return '';
    var url = assets.get('firstObject.small.url');
    return "backgorund: url("+url+") no-repeat; background-size: cover;";
    }.property('assets.@each')
    })
  2. @bricker bricker renamed this gist Aug 16, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @bricker bricker created this gist Aug 16, 2013.
    6 changes: 6 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    <script type="text/x-handlebars" id="articles">
    {{#each controller}}
    <figure class="img-wrapper" {{bindAttr style="view.imgWrapperStyle"}}>
    </figure>
    {{/each}}
    </script>
    8 changes: 8 additions & 0 deletions view.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    Kpcc.ArticlesView = Ember.View.extend({
    imgWrapperStyle: function() {
    if(!this.content.get('assets.length')) return "";
    var url;
    url = this.content.get('assets.firstObject.small.url');
    return "background:url("+url+") no-repeat;background-size:cover;";
    }.property('content.assets')
    });