1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-16 01:56:55 +00:00

Fix pinned cheers.

This commit is contained in:
SirStendec 2016-11-09 22:19:37 -05:00
parent d3262d4fff
commit fbf6a9ed8d
9 changed files with 208 additions and 83 deletions

View file

@ -35,6 +35,44 @@ FFZ.settings_info.bits_tags_container = {
}
FFZ.settings_info.bits_pinned = {
type: "boolean",
value: true,
category: "Chat Appearance",
name: "Display Pinned Cheers",
help: "Show pinned messages with bits at the top of chat in channels that have it enabled.",
on_update: function(val) {
utils.toggle_cls('ffz-hide-pinned-cheers')(!val);
}
}
FFZ.settings_info.bits_pinned_expand = {
type: "select",
options: {
0: "On Click (Default)",
1: "On Hover",
2: "Always"
},
value: 0,
process_value: utils.process_int(0),
category: "Chat Appearance",
name: "Expand Pinned Cheers",
help: "Set when to expand pinned cheers beyond a minimal height.",
on_update: function(val) {
utils.toggle_cls('ffz-pinned-cheer-expand-hover')(val === 1);
utils.toggle_cls('ffz-pinned-cheer-expand')(val === 2);
}
}
// --------------------
// Initialization
@ -43,6 +81,9 @@ FFZ.settings_info.bits_tags_container = {
FFZ.prototype.setup_bits = function() {
utils.toggle_cls('ffz-animate-bits')(this.settings.bits_animated);
utils.toggle_cls('ffz-show-bits-tags')(this.settings.bits_tags_container);
utils.toggle_cls('ffz-hide-pinned-cheers')(!this.settings.bits_pinned);
utils.toggle_cls('ffz-pinned-cheer-expand-hover')(this.settings.bits_pinned_expand === 1);
utils.toggle_cls('ffz-pinned-cheer-expand')(this.settings.bits_pinned_expand === 2);
var f = this,
Service = utils.ember_lookup('service:bits-rendering-config');

View file

@ -35,8 +35,10 @@ var FFZ = window.FrankerFaceZ,
subscribers: {info: 'Enable Subscribers-Only Mode'},
subscribersoff: {info: 'Disable Subscribers-Only Mode'},
emotesonly: {info: 'Enable Emotes-Only Mode'},
emotesonlyoff: {info: 'Disable Emotes-Only Mode'},
emoteonly: {info: 'Enable Emote-Only Mode'},
emoteonlyoff: {info: 'Disable Emote-Only Mode'},
unpin: {info: 'Unpin the current Pinned Cheer'}
},
BROADCASTER_COMMANDS = {

View file

@ -360,8 +360,9 @@ FFZ.prototype.setup_layout = function() {
'bottom: ' + video_bottom + 'px}' +
'body:not(.ffz-sidebar-swap) .cn-bar-fixed { right: 0 !important }' +
'body.ffz-sidebar-swap .cn-bar-fixed { left: 0 !important }' +
'.ffz-theater-stats .app-main.theatre .cn-hosting--bottom,' +
'.ffz-theater-stats .app-main.theatre .cn-metabar__more {' +
'max-width: calc(100% - 300px);' +
'max-width: calc(100% - 350px);' +
'bottom: ' + (theatre_video_bottom + 55) + 'px !important}' +
'.ffz-theater-stats:not(.ffz-theatre-conversations):not(.ffz-top-conversations) .app-main.theatre .cn-metabar__more {' +
'bottom: ' + (theatre_video_bottom + 90) + 'px !important}';
@ -382,12 +383,14 @@ FFZ.prototype.setup_layout = function() {
'left:' + width + 'px !important}' +
'body:not(.ffz-sidebar-swap) #main_col:not(.expandRight) .cn-bar-fixed {' +
'right: ' + width + 'px}' +
'body.ffz-sidebar-swap .theatre .cn-hosting--bottom,' +
'body.ffz-sidebar-swap .theatre .cn-metabar__more {' +
'left: ' + (width + 10) + 'px !important}' +
'body.ffz-sidebar-swap #main_col:not(.expandRight) .cn-bar-fixed {' +
'left: ' + width + 'px !important}' +
'.ffz-theater-stats .app-main.theatre .cn-hosting--bottom,' +
'.ffz-theater-stats .app-main.theatre .cn-metabar__more {' +
'max-width: calc(100% - ' + (width + 300) + 'px)}';
'max-width: calc(100% - ' + (width + 350) + 'px)}';
}
}

View file

@ -710,6 +710,8 @@ FFZ.prototype.save_aliases = function() {
FFZ.prototype._modify_chat_line = function(component, is_vod) {
var f = this,
Layout = utils.ember_lookup('service:layout'),
Chat = utils.ember_lookup('controller:chat'),
PinnedCheers = utils.ember_lookup('service:bits-pinned-cheers'),
Settings = utils.ember_settings();
component.reopen({
@ -724,7 +726,7 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
return f.tokenize_chat_line(this.get('msgObject'));
} catch(err) {
f.error("chat-line tokenizedMessage: " + err);
return this._super();
return this.get('tokenizedMessage');
}
}.property("msgObject.message", "isChannelLinksDisabled", "currentUserNick", "msgObject.from", "msgObject.tags.emotes"),
@ -756,7 +758,11 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
buildModIconsHTML: function() {
var user = this.get('msgObject.from'),
room_id = this.get('msgObject.room'),
is_tb = this.get('msgObject.twitchBotRejected'),
is_pinned_cheer = this.get('msgObject.payday_timestamp'),
room_id = is_pinned_cheer ? Chat.get('currentRoom.id') : this.get('msgObject.room'),
room = f.rooms && f.rooms[room_id],
deleted = this.get('msgObject.deleted'),
@ -767,11 +773,10 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
this_ul = this.get('ffzUserLevel'),
other_ul = room && room.room && room.room.get('ffzUserLevel') || 0,
is_tb = this.get('msgObject.twitchBotRejected'),
shouldnt_show =is_whisper || this_ul >= other_ul || (f.settings.mod_buttons.length === 0 && ! is_tb),
output;
if ( is_whisper || this_ul >= other_ul || (f.settings.mod_buttons.length === 0 && ! is_tb) )
if ( ! is_pinned_cheer && shouldnt_show )
return '';
output = ['<span class="mod-icons">'];
@ -781,50 +786,57 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
output.push('<a class="mod-icon html-tooltip tb-allow" title="Allowed' + TB_TOOLTIP + '">Allowed</a>');
}
for(var i=0, l = f.settings.mod_buttons.length; i < l; i++) {
var pair = f.settings.mod_buttons[i],
prefix = pair[0], btn = pair[1], had_label = pair[2], is_emoji = pair[3],
cmd, tip;
if ( is_emoji ) {
var setting = f.settings.parse_emoji,
token = f.emoji_data[is_emoji],
url = null;
if ( token ) {
if ( setting === 1 && token.tw )
url = token.tw_src;
else if ( setting === 2 && token.noto )
url = token.noto_src;
else if ( setting === 3 && token.one )
url = token.one_src;
if ( url )
prefix = '<img class="mod-icon-emoji" src="' + utils.quote_attr(url) + '">';
}
}
if ( btn === false ) {
if ( deleted )
output.push('<a class="mod-icon html-tooltip unban" title="Unban User" href="#">Unban</a>');
else
output.push('<a class="mod-icon html-tooltip ban' + (had_label ? ' custom' : '') + '" title="Ban User" href="#">' + (had_label ? prefix : 'Ban') + '</a>');
} else if ( btn === 600 )
output.push('<a class="mod-icon html-tooltip timeout' + (had_label ? ' custom' : '') + '" title="Timeout User (10m)" href="#">' + ( had_label ? prefix : 'Timeout') + '</a>');
else {
if ( typeof btn === "string" ) {
cmd = utils.replace_cmd_variables(btn, {name: user}, room && room.room, this.get('msgObject')).replace(/\s*<LINE>\s*/g, '\n');
tip = "Custom Command" + (cmd.indexOf("\n") !== -1 ? 's' : '') + '<br>' + utils.quote_san(cmd).replace('\n','<br>');
} else {
cmd = "/timeout " + user + " " + btn;
tip = "Timeout User (" + utils.duration_string(btn) + ")";
}
output.push('<a class="mod-icon html-tooltip' + (cmd.substr(0,9) === '/timeout' ? ' is-timeout' : '') + ' custom" data-cmd="' + utils.quote_attr(cmd) + '" title="' + tip + '" href="#">' + prefix + '</a>');
}
if ( is_pinned_cheer ) {
if ( PinnedCheers && PinnedCheers.canDismissPinnedCheer(this.get('parentView.userData.id'), this.get('parentView.isViewerModeratorOrHigher')) )
output.push('<a class="mod-icon html-tooltip pc-dismiss" title="Dismiss for Everyone">Dismiss</a>');
output.push('<a class="mod-icon html-tooltip pc-dismiss-local" title="Dismiss">Dismiss</a>');
}
if ( ! shouldnt_show )
for(var i=0, l = f.settings.mod_buttons.length; i < l; i++) {
var pair = f.settings.mod_buttons[i],
prefix = pair[0], btn = pair[1], had_label = pair[2], is_emoji = pair[3],
cmd, tip;
if ( is_emoji ) {
var setting = f.settings.parse_emoji,
token = f.emoji_data[is_emoji],
url = null;
if ( token ) {
if ( setting === 1 && token.tw )
url = token.tw_src;
else if ( setting === 2 && token.noto )
url = token.noto_src;
else if ( setting === 3 && token.one )
url = token.one_src;
if ( url )
prefix = '<img class="mod-icon-emoji" src="' + utils.quote_attr(url) + '">';
}
}
if ( btn === false ) {
if ( deleted )
output.push('<a class="mod-icon html-tooltip unban" title="Unban User" href="#">Unban</a>');
else
output.push('<a class="mod-icon html-tooltip ban' + (had_label ? ' custom' : '') + '" title="Ban User" href="#">' + (had_label ? prefix : 'Ban') + '</a>');
} else if ( btn === 600 )
output.push('<a class="mod-icon html-tooltip timeout' + (had_label ? ' custom' : '') + '" title="Timeout User (10m)" href="#">' + ( had_label ? prefix : 'Timeout') + '</a>');
else {
if ( typeof btn === "string" ) {
cmd = utils.replace_cmd_variables(btn, {name: user}, room && room.room, this.get('msgObject')).replace(/\s*<LINE>\s*/g, '\n');
tip = "Custom Command" + (cmd.indexOf("\n") !== -1 ? 's' : '') + '<br>' + utils.quote_san(cmd).replace('\n','<br>');
} else {
cmd = "/timeout " + user + " " + btn;
tip = "Timeout User (" + utils.duration_string(btn) + ")";
}
output.push('<a class="mod-icon html-tooltip' + (cmd.substr(0,9) === '/timeout' ? ' is-timeout' : '') + ' custom" data-cmd="' + utils.quote_attr(cmd) + '" title="' + tip + '" href="#">' + prefix + '</a>');
}
}
return output.join('') + '</span>';
},
@ -854,6 +866,9 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
},
buildBadgesHTML: function() {
if ( ! this.get('msgObject.room') && this.get('msgObject.payday_timestamp') )
this.set('msgObject.room', Chat.get('currentRoom.id'));
return '<span class="badges">' + f.render_badges(f.get_line_badges(this.get('msgObject'))) + '</span>';
},
@ -962,7 +977,8 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
FFZ.prototype._modify_chat_subline = function(component) {
var f = this;
var f = this,
PinnedCheers = utils.ember_lookup('service:bits-pinned-cheers');
this._modify_chat_line(component);
@ -971,17 +987,22 @@ FFZ.prototype._modify_chat_subline = function(component) {
attributeBindings: ["msgObject.tags.id:data-id", "msgObject.room:data-room", "msgObject.from:data-sender", "msgObject.deleted:data-deleted"],
didInsertElement: function() {
this.set('msgObject._line', this);
this.ffzRender();
if ( this.get('msgObject') ) {
this.set('msgObject._line', this);
this.ffzRender();
}
},
ffz_update: function() {
this.set('msgObject._line', this);
this.ffzRender();
if ( this.get('msgObject') ) {
this.set('msgObject._line', this);
this.ffzRender();
}
},
willClearRender: function() {
this.set('msgObject._line', null);
if ( this.get('msgObject') )
this.set('msgObject._line', null);
},
//didUpdate: function() { this.ffzRender(); },
@ -1122,6 +1143,9 @@ FFZ.prototype._modify_chat_subline = function(component) {
var cl = e.target.classList,
from = this.get("msgObject.from");
if ( ! from )
return;
/*if ( cl.contains('ffz-old-messages') )
return f._show_deleted(this.get('msgObject.room'));*/
@ -1136,7 +1160,13 @@ FFZ.prototype._modify_chat_subline = function(component) {
jQuery(e.target).trigger('mouseout');
e.preventDefault();
if ( cl.contains('tb-reject') )
if ( cl.contains('pc-dismiss-local') )
PinnedCheers.dismissLocalMessage();
else if ( cl.contains('pc-dismiss') )
PinnedCheers.dismissCurrentMessage(this.get('parentView.userData.id'));
else if ( cl.contains('tb-reject') )
this.actions.clickedTwitchBotResponse.call(this, this.get('msgObject.tags.id'), 'no');
else if ( cl.contains('tb-allow') )

View file

@ -633,7 +633,9 @@ FFZ.HoverPause = {
FFZ.prototype.modify_room_component = function(component) {
var f = this;
var f = this,
PinnedCheers = utils.ember_lookup('service:bits-pinned-cheers');
utils.ember_reopen_view(component, _.extend({
ffz_init: function() {
f._roomv = this;
@ -697,7 +699,10 @@ FFZ.prototype.modify_room_component = function(component) {
channel = this.get('room.channel');
if ( ! channel )
return;
else if ( ! channel.get('isLoaded') )
PinnedCheers && PinnedCheers.dismissLocalMessage();
if ( ! channel.get('isLoaded') )
channel.load().then(function() { t._initializeBits(channel) })
else
this._initializeBits(channel);

View file

@ -61,7 +61,7 @@ FFZ.channel_metadata = {};
// Version
var VER = FFZ.version_info = {
major: 3, minor: 5, revision: 363,
major: 3, minor: 5, revision: 367,
toString: function() {
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
}