This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
uservoice.user.js
120 lines (103 loc) · 3.66 KB
/
uservoice.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// ==UserScript==
// @name Uservoice Overrides
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Minimize some UI crap
// @author Matthew Batchelder
// @include /https:\/\/tribe.uservoice.com\/admin\/.*/
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
var mt_uservoice = {};
( function( $, my ) {
'use strict';
my.init = function() {
var $graph = $( '.cols-5.mb2 + .content-box' );
var $graph_body = $graph.find( '.content-box-body' );
var $graph_header = $graph.find( 'header' );
var $activity_stream = $( '#activity-stream' );
$graph.on( 'click', 'header', function( e ) {
if ( $graph_body.is( ':visible' ) ) {
$graph_body.hide();
} else {
$graph_body.show();
}
} );
$activity_stream.find( '.hfeed .hentry:not(.supported) h3.entry-title a' ).each( function() {
var $el = $( this );
var href = $el.attr( 'href' );
var $article = $el.closest( 'article' );
var $footer = $article.find( 'footer' );
var jqxhr = $.get( href );
jqxhr.done( function( data ) {
var $html = $( data );
var breadcrumbs = $html.find( '.breadcrumbs' ).html();
if ( breadcrumbs ) {
$footer.prepend( '<div class="tribe-breadcrumbs">' + breadcrumbs + ' @ </div>' );
}
var $chicklet = $html.find( '.vote_chicklet .chicklet' );
var votes = $chicklet.find( 'strong' ).html();
if ( votes ) {
$footer.prepend( '<div class="tribe-votes">' + votes + ' Votes</div>' );
}
} );
} );
$activity_stream.addClass( 'hide-supported' );
$activity_stream.find( '.activity-stream-header-table thead th[data-object-type="supported"]' ).addClass( 'is-disabled' );
$( '.blog-posts' ).closest( '.cols-span-1' ).hide();
$( '.activity-stream-header-table' ).each( function() {
var $table = $( this );
$table.find( 'tbody td' ).each( function() {
var $cell = $( this );
if ( '0' === $cell.html() ) {
$cell.hide();
$table.find( 'thead th[data-object-type="' + $cell.data( 'object-type' ) + '"]' ).hide();
}
} );
} );
my.build_styles();
};
my.build_styles = function() {
$( 'head' ).append( '<style id="bork-uservoice-styles"/>' );
my.$styles = $( document.getElementById( 'bork-uservoice-styles' ) );
my.$styles.html( [
'#nav {',
' opacity: 0.1;',
' transition: all 0.5s ease;',
'}',
'#nav:hover {',
' opacity: 1;',
'}',
'.cols-5.mb2 + .content-box .content-box-body {',
' display: none;',
'}',
'.cols-5.mb2 + .content-box > header {',
' cursor: pointer;',
'}',
'.placard-value {',
' font-size: 19px;',
'}',
'#activity-stream .tribe-breadcrumbs {',
' float: left;',
' line-height: 14px;',
' margin-right: .25rem;',
'}',
'.tribe-votes {',
' background: #fff;',
' border: 1px solid #b3b3b3;',
' border-radius: 5px;',
' padding: .25rem;',
' position: absolute;',
' right: 55px;',
' top: 12px;',
'}',
'#activity-stream .hentry {',
' position: relative;',
'}',
'' ].join( "\n" ) );
};
$( function() {
my.init();
} );
} )( jQuery, mt_uservoice );