Skip to content

Commit

Permalink
use l to like
Browse files Browse the repository at this point in the history
  • Loading branch information
dtinth committed Dec 21, 2012
1 parent 05adbd0 commit b9ba542
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions sjs.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function StateManager(onstate) {

function main() {

$('#version').html(' v0.1.2')
$('#version').html(' v0.1.3')

if (!ACCESS_TOKEN) {
return authenticationNeeded();
Expand Down Expand Up @@ -915,18 +915,22 @@ function FeedView(feed, navigation) {
}
return 0;
};

function scrollPic(direction) {
view.calculatePositionTable();
if (posTable.length == 0) return;
var cscroll = scroll.get();
function getCurrentScrollIndex() {
var index = 0;
var cscroll = scroll.get();
that.calculatePositionTable();
for (var i = 0; i < posTable.length; i ++) {
if (posTable[i] >= cscroll) {
index = i;
break;
}
}
return index;
}
function scrollPic(direction) {
if (posTable.length == 0) return;
var cscroll = scroll.get();
var index = getCurrentScrollIndex();
var target = index;
for (i = index; i >= 0 && i < posTable.length; i += direction) {
if (posTable[i] != posTable[target]) {
Expand All @@ -946,6 +950,12 @@ function FeedView(feed, navigation) {
if (e.keyCode == 75) {
scrollPic(-1);
}
if (e.keyCode == 76) {
var index = getCurrentScrollIndex();
if (activeView.like) {
activeView.like(index);
}
}
});

// view switching
Expand Down Expand Up @@ -1025,6 +1035,9 @@ function MediaListView(feed) {

var that = new MediaCollectionView($('#list-view').tpl(), feed);

that.like = function(index) {
that.getItemElements().eq(index).closest('.picture').find('[data-role="likeIcon"]').eq(0).click();
};
that.getItemElements = function() {
return that.dom.el.find('.image');
};
Expand Down

0 comments on commit b9ba542

Please sign in to comment.