Making WordPress.org

Changeset 225


Ignore:
Timestamp:
01/08/2014 04:56:09 PM (11 years ago)
Author:
nacin
Message:

Trac: CSS and JS for notifications. see #127.

Location:
sites/trunk/wordpress.org/public_html/style/trac
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/style/trac/wp-trac.css

    r222 r225  
    805805}
    806806
     807/* = Notifications */
     808.ticket-star {
     809    font-size: 32px;
     810    width: 32px;
     811    margin-right: 8px;
     812    color: #aaa;
     813}
     814.ticket-star:hover {
     815    cursor: pointer;
     816}
     817.ticket-star:hover,
     818.ticket-star.dashicons-star-filled {
     819    color: #21759b;
     820}
     821#notifications {
     822    margin-top: 1em;
     823}
     824#notifications .dashicons {
     825    vertical-align: text-bottom;
     826}
     827#notifications .star-this-ticket a {
     828    color: #333;
     829}
     830#notifications .count-1,
     831#notifications.count-0 .num-stars,
     832#notifications.count-1 .count-many {
     833    display: none;
     834}
     835#notifications.count-1 .count-1 {
     836    display: inline;
     837}
     838#notifications .block-notifications,
     839#notifications .unblock-notifications {
     840    color: #d31313;
     841    margin-left: 6px;
     842    margin-right: 6px;
     843}
     844#notifications .num-stars {
     845    font-size: 12px;
     846    margin-left: 6px;
     847}
     848#notifications a.watching-ticket,
     849#notifications p.receiving-notifications,
     850#notifications p.receiving-notifications-because,
     851#notifications p.not-receiving-notifications {
     852    display: none;
     853}
     854#notifications.subscribed a.watching-ticket {
     855    display: inline-block;
     856}
     857#notifications.block p.receiving-notifications-because,
     858#notifications.blocked p.not-receiving-notifications {
     859    display: block;
     860}
     861#notifications.subscribed p.receiving-notifications-because,
     862#notifications.subscribed p.not-receiving-notifications,
     863#notifications.subscribed a.watch-this-ticket {
     864    display: none;
     865}
     866#notifications.subscribed p.receiving-notifications {
     867    display: block;
     868}
     869
    807870/* =Link Colors */
    808871a:link,
  • sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js

    r216 r225  
    1 var wpTrac, coreKeywordList, gardenerKeywordList;
     1var vnpTrac, coreKeywordList, gardenerKeywordList;
    22
    33(function($){
     
    6969            });
    7070
    71             // Add After the Deadline
    72             $('textarea').addProofreader();
     71            // Add After the Deadline (only add it if it loaded)
     72            if ( $.isFunction( $.fn.addProofreader ) ) {
     73                $('textarea').addProofreader();
     74            }
    7375
    7476            $('.AtD_proofread_button').each(function() {
     
    366368            if ( ! testKeywords.length )
    367369                wpTrac.hiddenEl.val( wpTrac.originalKeywords.join(' ') );
    368         }
     370        },
     371
     372        notifications: (function() {
     373            var notifications, _endpoint, _ticket, star;
     374
     375            function init( endpoint, ticket ) {
     376                var current_star;
     377                _endpoint = endpoint;
     378                _ticket = ticket;
     379                notifications = $('#notifications');
     380                notifications.on( 'click', '.watch-this-ticket', subscribe )
     381                    .on( 'click', '.watching-ticket', unsubscribe )
     382                    .on( 'click', '.block-notifications', block )
     383                    .on( 'click', '.unblock-notifications', unblock );
     384
     385                current_star = notifications.hasClass('subscribed') ? 'filled' : 'empty';
     386                $('#ticket.trac-content > h2').prepend( '<div class="ticket-star dashicons dashicons-star-' + current_star + '"></div>' );
     387                star = $('.ticket-star');
     388                star.click( function() {
     389                    $(this).hasClass('dashicons-star-empty') ? subscribe() : unsubscribe();
     390                });
     391            }
     392
     393            function save( action ) {
     394                $.ajax({
     395                    type: 'POST',
     396                    url: _endpoint,
     397                    xhrFields: { withCredentials: true },
     398                    data: {
     399                        'trac-ticket-sub': _ticket,
     400                        action: action
     401                    }
     402                });
     403            }
     404
     405            function subscribe() {
     406                save( 'subscribe' );
     407                notifications.removeClass('blocked').addClass('subscribed');
     408                star.toggleClass('dashicons-star-empty dashicons-star-filled');
     409                if ( notifications.hasClass('receiving') ) {
     410                    notifications.addClass('block');
     411                }
     412                change_count( 1 );
     413                return false;
     414            }
     415
     416            function unsubscribe() {
     417                save( 'unsubscribe' );
     418                notifications.removeClass('subscribed');
     419                star.toggleClass('dashicons-star-empty dashicons-star-filled');
     420                if ( notifications.hasClass('receiving') ) {
     421                    notifications.addClass('block');
     422                }
     423                change_count( -1 );
     424                return false;
     425            }
     426
     427            function change_count( delta ) {
     428                var count = parseInt( notifications.find('.count').text(), 10 ) + delta;
     429                notifications.find('.count').text( count );
     430                notifications.toggleClass( 'count-0', count === 0 ).toggleClass( 'count-1', count === 1 );
     431            }
     432
     433            function block() {
     434                save( 'block' );
     435                notifications.removeClass('block').addClass('blocked');
     436                return false;
     437            }
     438
     439            function unblock() {
     440                save( 'unblock' );
     441                notifications.removeClass('blocked').addClass('block');
     442                return false;
     443            }
     444
     445            return {
     446                init: init
     447            };
     448        }())
    369449
    370450    };
Note: See TracChangeset for help on using the changeset viewer.