1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-17 10:16:57 +00:00

3.5.420. The big meme commit. Now I can actually work on stuff again. This adds handling for Top Cheers. Also, finally commit the schedule code I keep forgetting.

This commit is contained in:
SirStendec 2017-01-20 21:20:45 -05:00
parent 03c825c398
commit 0b21f20906
9 changed files with 367 additions and 54 deletions

View file

@ -60,8 +60,16 @@ FFZ.settings_info.bits_tags_container = {
FFZ.settings_info.bits_pinned = {
type: "boolean",
value: true,
type: "select",
options: {
0: "Disabled",
1: "Show Recent",
2: "Show Top",
3: "Show All (Default)"
},
value: 3,
process_value: utils.process_int(3, 0, 3),
category: "Chat Appearance",
@ -69,30 +77,15 @@ FFZ.settings_info.bits_pinned = {
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);
}
}
var PinnedCheers = utils.ember_lookup('service:bits-pinned-cheers');
if ( val === 3 || ! PinnedCheers )
return;
if ( val !== 1 )
PinnedCheers.set('recentPinnedCheer', null);
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);
if ( val !== 2 )
PinnedCheers.set('topPinnedCheer', null);
}
}
@ -114,12 +107,12 @@ FFZ.settings_info.bits_disable_charity = {
FFZ.prototype.setup_bits = function() {
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);
this.update_views('component:bits/chat-token', this._modify_bits_token);
var f = this,
Service = utils.ember_lookup('service:bits-emotes'),
PinnedCheers = utils.ember_lookup('service:bits-pinned-cheers'),
image_css = function(images) {
return 'background-image: url("' + images[1] + '");' +
@ -144,6 +137,27 @@ FFZ.prototype.setup_bits = function() {
'}';
};
if ( PinnedCheers ) {
PinnedCheers.reopen({
_updatePinnedCheerData: function(data) {
var setting = f.settings.bits_pinned;
if ( setting < 2 )
data.top = null;
else if ( data.top )
data.top.is_pinned_cheer = 2;
if ( setting !== 3 && setting !== 1 )
data.recent = null;
else if ( data.recent )
data.recent.is_pinned_cheer = true;
return this._super(data);
}
});
FFZ.settings_info.bits_pinned.on_update.call(this, this.settings.bits_pinned);
}
if ( Service ) {
Service.reopen({
ffz_has_css: false,
@ -274,4 +288,27 @@ FFZ.prototype.setup_bits = function() {
if ( Service.get('isLoaded') )
Service.loadRenderConfig();
}
FFZ.prototype._modify_bits_token = function(component) {
var f = this;
utils.ember_reopen_view(component, {
ffz_init: function() {
this.ffzRender();
},
ffzRender: function() {
var el = this.get('element'),
prefix = this.get('prefix'),
amount = this.get('amount');
el.innerHTML = f.render_token(false, false, true, {
type: 'bits',
amount: amount,
prefix: prefix
});
}.observes('prefix', 'amount')
})
}

View file

@ -422,10 +422,6 @@ FFZ.prototype.modify_channel_redesign = function(view) {
f._credesign = null;
},
handleScroll: function(top) {
this._super();
},
ffzUpdateCoverHeight: function() {
var old_height = this.channelCoverHeight,
setting = f.settings.hide_channel_banner,

View file

@ -44,7 +44,8 @@ var FFZ = window.FrankerFaceZ,
emoteonly: {info: 'Enable Emote-Only Mode'},
emoteonlyoff: {info: 'Disable Emote-Only Mode'},
unpin: {info: 'Unpin the current Pinned Cheer'}
unpin: {info: 'Unpin the current Pinned Cheer'},
reset: {info: 'Clear the current Top Cheer'}
},
BROADCASTER_COMMANDS = {

View file

@ -679,7 +679,8 @@ FFZ.prototype.setup_line = function() {
this.update_views('component:video/rechat/chat-message', this._modify_vod_line);
this.update_views('component:chat/message-line', this._modify_chat_subline);
this.update_views('component:chat/whisper-line', function(x) { return f._modify_chat_subline(x, true) });
this.update_views('component:bits/pinned-cheers/top-cheer-line', this._modify_top_cheer_line);
this.update_views('component:bits/pinned-cheers/top-cheer', this._modify_top_cheer);
// Store the capitalization of our own name.
var user = this.get_user();
@ -694,6 +695,42 @@ FFZ.prototype.save_aliases = function() {
}
FFZ.prototype._modify_top_cheer = function(component) {
var f = this;
utils.ember_reopen_view(component, {
ffz_init: function() {
var PinnedCheers = utils.ember_lookup('service:bits-pinned-cheers'),
el = this.get('element'),
container = el && el.querySelector('.pinned-cheer__top-bar');
if ( ! PinnedCheers || ! container )
return;
var btn_dismiss = utils.createElement('a', 'mod-icon html-tooltip pc-dismiss-local', 'Dismiss'),
mod_icons = utils.createElement('div', 'mod-icons', btn_dismiss);
btn_dismiss.title = 'Dismiss';
container.insertBefore(mod_icons, container.firstElementChild);
btn_dismiss.addEventListener('click', function() {
PinnedCheers.dismissLocalMessage();
});
}
});
}
FFZ.prototype._modify_top_cheer_line = function(component) {
var f = this;
component.reopen({
ffzRender: function() {
var el = this.get('element');
el.innerHTML = this.buildFromHTML() + '<span class="colon">:</span> ';
}
})
}
FFZ.prototype._modify_chat_line = function(component, is_vod) {
var f = this,
Layout = utils.ember_lookup('service:layout'),
@ -729,6 +766,11 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
this.$(".badges").html(f.render_badges(f.get_line_badges(this.get('msgObject'))));
},
ffzPinnedParent: function() {
var is_pinned_cheer = this.get('msgObject.is_pinned_cheer');
return is_pinned_cheer === 2 ? this.get('parentView.parentView.parentView.parentView.parentView') : this.get('parentView');
}.property('msgObject.is_pinned_cheer'),
ffzUserLevel: function() {
if ( this.get('isStaff') )
return 5;
@ -747,9 +789,9 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
var user = this.get('msgObject.from'),
is_tb = this.get('msgObject.twitchBotRejected'),
is_pinned_cheer = this.get('msgObject.payday_timestamp'),
is_pinned_cheer = this.get('msgObject.is_pinned_cheer'),
room_id = is_pinned_cheer ? Chat.get('currentRoom.id') : this.get('msgObject.room'),
room_id = this.get('msgObject.room'),
room = f.rooms && f.rooms[room_id],
deleted = this.get('msgObject.deleted'),
@ -774,9 +816,11 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
}
if ( is_pinned_cheer ) {
if ( PinnedCheers && PinnedCheers.canDismissPinnedCheer(this.get('parentView.userData.id'), this.get('parentView.isViewerModeratorOrHigher')) )
var parent = this.get('ffzPinnedParent');
if ( parent && PinnedCheers && PinnedCheers.canDismissPinnedCheer(parent.get('userData.id'), parent.get('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 ( is_pinned_cheer !== 2 )
output.push('<a class="mod-icon html-tooltip pc-dismiss-local" title="Dismiss">Dismiss</a>');
}
if ( ! shouldnt_show )
@ -1157,7 +1201,10 @@ FFZ.prototype._modify_chat_subline = function(component, is_whisper) {
PinnedCheers.dismissLocalMessage();
else if ( cl.contains('pc-dismiss') )
PinnedCheers.dismissCurrentMessage(this.get('parentView.userData.id'));
PinnedCheers.dismissMessage(
this.get('ffzPinnedParent.userData.id'),
this.get('msgObject.is_pinned_cheer') === '2' ? 'top' : 'recent'
);
else if ( cl.contains('tb-reject') )
this.actions.clickedTwitchBotResponse.call(this, this.get('msgObject.tags.id'), 'no');

View file

@ -115,7 +115,6 @@ FFZ.prototype.modify_persistent_player = function(player) {
ffz_init: function() {
var t = this;
this.$().off('mousewheel').on('mousewheel', function(event) {
f.log("Player-Scroll", event);
if ( ! f.settings.player_volume_scroll )
return;