|
// Add this to the User Scripts of your Fluid App |
|
|
|
// Only show user name and avatar for first message in a group of messages |
|
// Thanks to reissbaker for the first iteration of this functionality. |
|
|
|
window.onload = function(e) { |
|
!function($, App) { |
|
var initialized = false; |
|
var updateUI = function() { |
|
var $pic, $picLI, index, $prevLI, $prevPic, |
|
$picSeparator, $picContent, |
|
$pics = $('.userpic img' + (!initialized ? '' : ':visible')), |
|
SPACING = '3px'; |
|
|
|
initialized = true; |
|
|
|
for(index = $pics.length - 1; index >= 0; index--) { |
|
$pic = $($pics[index]); |
|
$picLI = $pic.closest('li'); |
|
if($picLI.attr('data-seen')) break; |
|
|
|
$picLI.attr('data-seen', true); |
|
$prevLI = $picLI.prev(); |
|
|
|
if($prevLI) { |
|
$prevPic = $prevLI.find('.userpic img'); |
|
$picSeparator = $picLI.find('.separator'); |
|
if($prevPic.attr('src') === $pic.attr('src')) { |
|
$pic.css('visibility', 'hidden'); |
|
$picLI.find('.user').css('visibility', 'hidden'); |
|
$picSeparator.hide(); |
|
$picLI.css('margin-top', '-5px'); |
|
} |
|
} |
|
} |
|
}; |
|
|
|
App.on('newMessage', updateUI); |
|
App.on('newPrivateMessage', updateUI); |
|
App.on('routeClicked', updateUI); |
|
updateUI(); |
|
}(jQuery, App) |
|
} |
|
|
|
// shift+up and shift+down to move between channels |
|
// Thanks to h4rry for this bit. |
|
|
|
$(document).bind('keydown', function(e){ |
|
var shifted = e.shiftKey; |
|
|
|
if (e.keyCode == 40 && shifted) { |
|
var length = App.channels.length - 1, |
|
curIndex = App.channels.indexOf(currentChannel), |
|
nextIndex = curIndex + 1; |
|
if (nextIndex > length) nextIndex = 0; |
|
App.router.routePath(App.channels.at(nextIndex).get('app_url')) |
|
return false; |
|
} |
|
|
|
if (e.keyCode == 38 && shifted) { |
|
var length = App.channels.length - 1, |
|
curIndex = App.channels.indexOf(currentChannel), |
|
nextIndex = curIndex - 1; |
|
if (nextIndex < 0) nextIndex = length; |
|
App.router.routePath(App.channels.at(nextIndex).get('app_url')) |
|
return false; |
|
} |
|
}); |
|
|
|
$('.main-wrapper').click(function(){ App.channelView.focusMessageForm(); }) |