diff --git a/client/helpers/handlebars.js b/client/helpers/handlebars.js index 01c32a8df..886df5cc1 100644 --- a/client/helpers/handlebars.js +++ b/client/helpers/handlebars.js @@ -1,6 +1,9 @@ // ** Handlebars helpers ** -Handlebars.registerHelper('each_with_index', function(items, options) { +Handlebars.registerHelper('eachWithRank', function(items, options) { + console.log('======= eachWithRank ========') + // note: cannot use this because it would delete and recreate all nodes + items.rewind() var out = ''; items.forEach(function(item, i){ var key = 'Branch-' + i; @@ -8,10 +11,9 @@ Handlebars.registerHelper('each_with_index', function(items, options) { return options.fn(_.extend(item, {rank: i})); }); }); - console.log('each_with_index:') - console.log(out) return out; }); + Handlebars.registerHelper('getSetting', function(setting, defaultArgument){ return getSetting(setting, defaultArgument); }); diff --git a/client/helpers/router.js b/client/helpers/router.js index 33617a896..5c7a07167 100644 --- a/client/helpers/router.js +++ b/client/helpers/router.js @@ -256,15 +256,14 @@ PostsListController = RouteController.extend({ Session.set('postsLimit', limit); // get posts and decorate them with rank property + // note: using handlebars helper instead // posts = posts.map(function (post, index) { // post.rank = index; // return post; // }); - console.log('postsWithRank:') - console.log(posts) return { - posts: posts + postsList: posts } }, after: function() { diff --git a/client/views/posts/post_item.js b/client/views/posts/post_item.js index 287205654..58cae106d 100644 --- a/client/views/posts/post_item.js +++ b/client/views/posts/post_item.js @@ -78,7 +78,6 @@ Template.post_item.helpers({ Template.post_item.rendered = function(){ // animate post from previous position to new position - console.log(this) var instance = this; var $instance = $(instance.firstNode.nextSibling); var rank = instance.data.rank; // use jQuery instead of decorating the data object @@ -87,15 +86,16 @@ Template.post_item.rendered = function(){ var previousPosition = 0; var newPosition = $instance.position().top; - console.log('-----------------------') - console.log('headline: '+this.data.headline) - console.log('new rank: '+(rank+1)) - console.log('newPosition: '+newPosition) + // console.log('-----------------------') + // console.log('headline: '+this.data.headline) + // console.log('new rank: '+(rank+1)) + // console.log('newPosition: '+newPosition) // if element has a currentPosition (i.e. it's not the first ever render) if(previousPosition = instance.currentPosition){ // calculate difference between old position and new position and send element here var delta = previousPosition - newPosition; + // console.log('deta: '+delta) $instance.css("top", delta + "px"); } diff --git a/client/views/posts/posts_list.html b/client/views/posts/posts_list.html index ca0feb224..4c3171568 100644 --- a/client/views/posts/posts_list.html +++ b/client/views/posts/posts_list.html @@ -1,8 +1,8 @@