Skip to content
Extraits de code Groupes Projets
inbox.js 2,16 ko
Newer Older
  • Learn to ignore specific revisions
  • danielgrippi's avatar
    danielgrippi a validé
    /*   Copyright (c) 2010-2011, Diaspora Inc.  This file is
    
    danielgrippi's avatar
    danielgrippi a validé
     *   licensed under the Affero General Public License version 3 or later.  See
     *   the COPYRIGHT file.
     */
    
    //= require jquery.autoSuggest.custom
    
    danielgrippi's avatar
    danielgrippi a validé
    
    $(document).ready(function(){
    
      $(document).on('click', '.conversation-wrapper', function(){
    
        var conversation_path = $(this).data('conversation-path');
    
        $.getScript(conversation_path, function() {
    
    Dan Hansen's avatar
    Dan Hansen a validé
          Diaspora.page.directionDetector.updateBinds();
    
    
        history.pushState(null, "", conversation_path);
    
    MrZYX's avatar
    MrZYX a validé
    
        var conv = $(this).children('.stream_element'),
    
            cBadge = $("#conversations_badge .badge_count");
    
    MrZYX's avatar
    MrZYX a validé
        if(conv.hasClass('unread') ){
          conv.removeClass('unread');
        }
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
        if(cBadge.html() !== null) {
    
    MrZYX's avatar
    MrZYX a validé
          cBadge.html().replace(/\d+/, function(num){
            num = parseInt(num);
            cBadge.html(parseInt(num)-1);
            if(num == 1) {
              cBadge.addClass("hidden");
            }
          });
        }
    
    
        return false;
      });
    
      $(window).bind("popstate", function(){
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
        if (location.href.match(/conversations\/\d+/) !== null) {
    
    MrZYX's avatar
    MrZYX a validé
    	  $.getScript(location.href, function() {
    
    Dan Hansen's avatar
    Dan Hansen a validé
            Diaspora.page.directionDetector.updateBinds();
    
    MrZYX's avatar
    MrZYX a validé
          });
    
    MrZYX's avatar
    MrZYX a validé
          return false;
        }
    
    danielgrippi's avatar
    danielgrippi a validé
      });
    
      $('#conversation_inbox .stream').infinitescroll({
        navSelector  : ".pagination",
                     // selector for the paged navigation (it will be hidden)
        nextSelector : ".pagination a.next_page",
                     // selector for the NEXT link (to page 2)
        itemSelector : "#conversation_inbox .conversation",
                     // selector for all items you'll retrieve
        localMode: true,
        debug: false,
        donetext: "no more.",
        loadingText: "",
    
        loadingImg: ImagePaths.get('ajax-loader.gif')
    
    danielgrippi's avatar
    danielgrippi a validé
      }, function(){
    
        $('.conversation-wrapper', '.stream').bind('mousedown', function(){
    
    danielgrippi's avatar
    danielgrippi a validé
          bindIt($(this));
        });
      });
    
      // kill scroll binding
      $(window).unbind('.infscr');
    
    danielgrippi's avatar
    danielgrippi a validé
      // hook up the manual click guy.
      $('a.next_page').click(function(){
        $(document).trigger('retrieve.infscr');
        return false;
      });
    
    danielgrippi's avatar
    danielgrippi a validé
      // remove the paginator when we're done.
      $(document).ajaxError(function(e,xhr,opt){
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
        if (xhr.status == 404) { $('a.next_page').remove(); }
    
    danielgrippi's avatar
    danielgrippi a validé
      });
    });