<commit_before>// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later

app.views.Notifications = Backbone.View.extend({

  events: {
    "click .unread-toggle" : "toggleUnread",
    "click #mark_all_read_link": "markAllRead"
  },

  initialize: function() {
    $(".unread-toggle .entypo").tooltip();
    app.helpers.timeago($(document));
  },

  toggleUnread: function(evt) {
    var note = $(evt.target).closest(".stream_element");
    var unread = note.hasClass("unread");

    if (unread){ this.setRead(note.data("guid")); }
    else { this.setUnread(note.data("guid")); }
  },

  getAllUnread: function(){ return $('.media.stream_element.unread'); },

  setRead: function(guid) { this.setUnreadStatus(guid, false); },

  setUnread: function(guid){ this.setUnreadStatus(guid, true); },

  setUnreadStatus: function(guid, state){
    $.ajax({
      url: "/notifications/" + guid,
      data: { set_unread: state },
      type: "PUT",
      context: this,
      success: this.clickSuccess
    });
  },

  clickSuccess: function(data) {
    var type = $('.stream_element[data-guid=' + data["guid"] + ']').data('type');
    this.updateView(data["guid"], type, data["unread"]);
  },

  markAllRead: function(){
    var self = this;
    this.getAllUnread().each(function(i, el){
      self.setRead($(el).data("guid"));
    });
  },

  updateView: function(guid, type, unread) {
    var change = unread ? 1 : -1,
        all_notes = $('ul.nav > li:eq(0) .badge'),
        type_notes = $('ul.nav > li[data-type=' + type + '] .badge'),
        header_badge = $('#notification_badge .badge_count'),
        note = $('.stream_element[data-guid=' + guid + ']'),
        markAllReadLink = $('a#mark_all_read_link'),<commit_msg>Notification dropdown: 'mark all as read' link scroll fix<commit_after>// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later

app.views.Notifications = Backbone.View.extend({

  events: {
    "click .unread-toggle" : "toggleUnread",
    "click #mark_all_read_link": "markAllRead"
  },

  initialize: function() {
    $(".unread-toggle .entypo").tooltip();
    app.helpers.timeago($(document));
  },

  toggleUnread: function(evt) {
    var note = $(evt.target).closest(".stream_element");
    var unread = note.hasClass("unread");

    if (unread){ this.setRead(note.data("guid")); }
    else { this.setUnread(note.data("guid")); }
  },

  getAllUnread: function(){ return $('.media.stream_element.unread'); },

  setRead: function(guid) { this.setUnreadStatus(guid, false); },

  setUnread: function(guid){ this.setUnreadStatus(guid, true); },

  setUnreadStatus: function(guid, state){
    $.ajax({
      url: "/notifications/" + guid,
      data: { set_unread: state },
      type: "PUT",
      context: this,
      success: this.clickSuccess
    });
  },

  clickSuccess: function(data) {
    var type = $('.stream_element[data-guid=' + data["guid"] + ']').data('type');
    this.updateView(data["guid"], type, data["unread"]);
  },

  markAllRead: function(evt){
    if(evt) { evt.preventDefault(); }
    var self = this;
    this.getAllUnread().each(function(i, el){
      self.setRead($(el).data("guid"));
    });
  },

  updateView: function(guid, type, unread) {
    var change = unread ? 1 : -1,
        all_notes = $('ul.nav > li:eq(0) .badge'),
        type_notes = $('ul.nav > li[data-type=' + type + '] .badge'),
        header_badge = $('#notification_badge .badge_count'),
        note = $('.stream_element[data-guid=' + guid + ']'),
        markAllReadLink = $('a#mark_all_read_link'),
{'fraction_non_alphanumeric': 0.19182997515870825, 'fraction_numerical': 0.018216947281258625, 'mean_word_length': 3.5757575757575757, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7245211', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1265, 'n_words': 215}