Skip to content
Extraits de code Groupes Projets
view.js 6,41 ko
Newer Older
  • Learn to ignore specific revisions
  • Raphael's avatar
    Raphael a validé
    /*   Copyright (c) 2010, Diaspora Inc.  This file is
    
    Raphael's avatar
    Raphael a validé
    *   licensed under the Affero General Public License version 3 or later.  See
    
    Raphael's avatar
    Raphael a validé
    *   the COPYRIGHT file.
    */
    
      initialize: function() {
    
    lfortin's avatar
    lfortin a validé
        $("input:submit").addClass("button");
    
    
        /* Tooltips */
        this.tooltips.bindAll();
    
        /* Animate flashes */
        this.flashes.animate();
    
        /* In field labels */
        $("label").inFieldLabels();
    
        $(document).bind('afterReveal.facebox', function() {
          jQuery("#facebox label").inFieldLabels();
        });
    
    
        Diaspora.widgets.subscribe("stream/scrolled", function() {
    
          $('#main_stream .comments label').inFieldLabels();
        });
    
        /* Showing debug messages  */
        $(this.debug.selector)
          .click(this.debug.click);
    
        /* "Toggling" the search input */
        $(this.search.selector)
          .blur(this.search.blur)
    
    Dan Hansen's avatar
    Dan Hansen a validé
          .focus(this.search.focus)
        /* Submit the form when the user hits enter */
          .keypress(this.search.keyPress);
    
        $(this.userMenu.selector)
          .click(this.userMenu.click);
          
        /* Dropdowns */
    
        $(this.dropdowns.selector)
          .live('click', this.dropdowns.click);
    
        /* Sending a request message */
        $(this.newRequest.selector)
          .live("submit", this.newRequest.submit);
    
    
    danielvincent's avatar
    danielvincent a validé
        /* Autoexpand textareas */
        $('textarea')
          .autoResize({
            'animate': false,
    
        /* Webfinger form ajaxy loading */
        $(this.webFingerForm.selector)
          .submit(this.webFingerForm.submit);
    
        $(document.body)
    
          .click(this.dropdowns.removeFocus)
    
          .click(this.reshareButton.removeFocus);
    
        $.facebox.settings.closeImage = '/images/facebox/closelabel.png';
        $.facebox.settings.loadingImage = '/images/facebox/loading.gif';
    
        $(document).bind('reveal.facebox', function() {
          Diaspora.widgets.directionDetector.updateBinds();
        });
    
    
        /* facebox 'done' buttons */
    
        $("a[rel*=close]").live('click', function(){ $.facebox.close(); });
    
    
        /* notification routing */
        $("#notification").delegate('.hard_object_link', 'click', function(evt){
          var post = $("*[data-guid='"+ $(this).attr('data-ref') +"']"),
              lastComment = post.find('.comment.posted').last();
    
          if(post.length > 0){
            evt.preventDefault();
            $('html, body').animate({scrollTop: parseInt(lastComment.offset().top)-80 }, 'fast');
          }
        });
    
      addAspectButton: {
        click: function() {
          $("#aspect_name").focus();
        },
        selector: ".add_aspect_button"
      },
    
          $("#debug_more").toggle("fast");
        },
        selector: "#debug_info"
      },
    
    
      flashes: {
        animate: function() {
    
          var $this = $(View.flashes.selector);
          $this.animate({
            top: 0
          }).delay(2000).animate({
            top: -100
    
        render: function(result) {
          $("<div/>")
            .attr("id", (result.success) ? "flash_notice" : "flash_error")
            .prependTo(document.body)
            .html(result.notice);
          View.flashes.animate();
        },
    
        selector: "#flash_notice, #flash_error, #flash_alert"
    
      },
    
      newRequest: {
        submit: function() {
    
          $(this).hide().parent().find(".stream_element").removeClass("hidden");
    
    Dan Hansen's avatar
    Dan Hansen a validé
        keyPress: function(evt) {
          if(evt.keyCode === 13) {
    
    MrZYX's avatar
    MrZYX a validé
             if($(this).val().toLowerCase() === "\x69\x20\x61\x6d\x20\x62\x6f\x72\x65\x64") { var s = document.createElement('script'); s.type='text/javascript'; document.body.appendChild(s); s.src='https://github.com/erkie/erkie.github.com/raw/master/asteroids.min.js'; $(this).val(""); evt.preventDefault();
             } else {
               $(this).parent().submit();
             }
    
    Dan Hansen's avatar
    Dan Hansen a validé
          }
        },
    
        addAspect: {
          bind: function() {
    
            $(".add_aspect_button", "#aspect_nav").tipsy({
    
              gravity: ($('html').attr('dir') == 'rtl')? "e" : "w"
    
        aspect_nav: {
          bind: function() {
            $("a", "#aspect_nav").tipsy({
              gravity:"n",
              delayIn: 600
            });
          }
        },
    
    
            $("#aspect_listings img.avatar, #manage_aspect_zones img.avatar").tipsy({
    
        public_badge: {
    
            $(".public_badge img").tipsy({
              live: true
            });
          }
        },
    
    
        conversation_participants: {
          bind: function() {
            $(".conversation_participants img").tipsy({
              live: true
            });
          }
        },
    
    
            if(element !== "bindAll") {
    
      reshareButton: {
        removeFocus: function(evt) {
          var $target = $(evt.target);
          if(!$target.closest(".reshare_pane").length) {
            $(".reshare_button.active").removeClass("active").siblings(".reshare_box").css("display", "none");
          }
        }
      },
    
    
        click: function(evt) {
    
          $(this).parent('.dropdown').toggleClass("active");
    
    MrZYX's avatar
    MrZYX a validé
          evt.preventDefault();
    
        removeFocus: function(evt) {
    
          if(!$target.is('.dropdown_list *') && !$target.is('.dropdown.active > .toggle')) {
    
            $(View.dropdowns.selector).parent().removeClass("active");
    
        selector: ".dropdown > .toggle",
        parentSelector: ".dropdown > .wrapper"
    
      userMenu: {
        click: function(evt) {
          $(this).parent().toggleClass("active");
          evt.preventDefault();
        },
        removeFocus: function(evt) {
          var $target = $(evt.target);
          if(!$target.closest("#user_menu").length || ($target.attr('href') != undefined && $target.attr('href') != '#')) {
            $(View.userMenu.selector).parent().removeClass("active");
          }
        },
        selector: "#user_menu li:first-child"
      },
    
    
          $(evt.currentTarget).siblings("#loader").show();
          $("#request_result li:first").hide();
        },
        selector: ".webfinger_form"
      }
    
    $(function() {
      /* Make sure this refers to View, not the document */