Announcement

Collapse
No announcement yet.

User subscribe button at conversation_userinfo

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    User subscribe button at conversation_userinfo

    I tried and failed totally because of my js/jQuery skills.
    I need a mod or your help (both paid) to show the user-subscribe-button at the conversation-userinfo.
    I got the button with the correct buttonType or buttonlabel but I don't know how to edit or write the js/ jQuery part to get the correct function for add/ delete etc.
    My forum closed !

    #2
    Take a look at how the Subscribe button on Profile page was implemented.
    Helpful? Donate. Thanks!
    Buy me a coffeePayPal QR Code
    Fast VPS Host for vBulletin:
    A2 Hosting & IONOS

    Comment


      #3
      Thanks for answering...
      At the profile page the button use the js-file profile-sidebar-rollup. This file contain a selector class profile-sidebar-widget witch is in function A ... but is A now = jQuery or $ ?
      Code:
      function(A){var B=[".profile-sidebar-widget"];if(!vBulletin.pageHasSelectors(B)){return false}if(vBulletin.isAlreadyLoaded("profile")){}A(document).ready(function(
      I don't understand that code...

      I have this code in a template and display it about the conversation_userstats t-hook. Everything show up correctly...but it is not working to subscribe / unsubscribe because of the missing jQuery

      Code:
      <vb:if condition="isset($profileSubscribeButtonInfo) AND is_array($profileSubscribeButtonInfo) AND count($profileSubscribeButtonInfo) > 0">
                          <vb:if condition="!empty($profileSubscribeButtonInfo['showSubscribeButton'])">
                              <li><button class="action_button {vb:raw profileSubscribeButtonInfo.buttonType}_button subscribe-btn b-button {vb:raw profileSubscribeButtonInfo.buttonCSS} js-movable-toolbar-button" data-userid="{vb:raw profileSubscribeButtonInfo.userid}" id="add_{vb:raw profileSubscribeButtonInfo.userid}"{vb:raw profileSubscribeButtonInfo.buttonState}>{vb:phrase {vb:raw profileSubscribeButtonInfo['buttonLabelPhraseId']}}</button></li>
                          </vb:if>
                      </vb:if>
      I only need this two functions (but with all the variables in it I don't get it):

      Code:
      function() {
        if (!A(this).hasClass("subscribepending_button")) {
          var Y = A(this);
          var a = parseInt(Y.attr("data-userid"));
          var Z = "";
          if (Y.hasClass("subscribe_button")) {
            Z = "add"
          } else {
            if (Y.hasClass("unsubscribe_button")) {
              Z = "delete"
            }
          } if ((typeof(a) == "number") && Z) {
            A.ajax({
              url: vBulletin.getAjaxBaseurl() + "/profile/follow-button?do=" + Z + "&follower=" + a + "&type=follow_members",
              type: "POST",
              dataType: "json",
              success: function(c) {
                if (c == 1 || c == 2) {
                  if (Z == "add") {
                    var b = (c == 1) ? "subscribed" : "subscribepending";
                    var d = (c == 1) ? "following" : "following_pending";
                    Y.removeClass("subscribe_button").addClass(b + "_button b-button").find(".js-button__text-primary").text(vBulletin.phrase.get(d))
                  } else {
                    if (Z == "delete") {
                      Y.removeClass("subscribed_button unsubscribe_button b-button b-button--special").addClass("subscribe_button b-button b-button--secondary").find(".js-button__text-primary").text(vBulletin.phrase.get("follow"))
                    }
                  }
                  location.reload()
                } else {
                  if (c.errors) {
                    openAlertDialog({
                      title: vBulletin.phrase.get("profile_guser"),
                      message: vBulletin.phrase.get(c.errors[0]),
                      iconType: "error"
                    })
                  }
                }
              },
              error: function() {
                openAlertDialog({
                  title: vBulletin.phrase.get("profile_guser"),
                  message: vBulletin.phrase.get("unable_to_contact_server_please_try_again"),
                  iconType: "error"
                })
              }
            })
          }
        }
      }
      Code:
      function(Y) {
        A(this).html(vBulletin.phrase.get("following_remove")).addClass("b-button").toggleClass("subscribed_button unsubscribe_button b-button--special b-button--secondary")
      }
      My forum closed !

      Comment


        #4
        The code is minified and obfuscated for faster load performance. So yeah A = $ in the particular code you posted. It surely takes time to understand the code but if you are well versed in Javascript and jQuery, it's not impossible to understand what the code does. You don't have to copy the code as is but just understand the logic to implement the Subscribe/Unsubscribe button.
        Helpful? Donate. Thanks!
        Buy me a coffeePayPal QR Code
        Fast VPS Host for vBulletin:
        A2 Hosting & IONOS

        Comment


          #5
          Originally posted by glennrocksvb View Post
          but if you are well versed in Javascript and jQuery
          Iam not but I will look into it again when I got more free time. I bought you a coffee for your support and that great forum
          My forum closed !

          Comment


          • glennrocksvb
            glennrocksvb commented
            Editing a comment
            Thanks for the coffee! ☕

        Users Viewing This Page

        Collapse

        There is 1 user viewing this forum topic.

        • Guest Guest

        Latest Posts

        Collapse

        Working...
        X
        Searching...Please wait.
        An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

        Please push the back button and reload the previous window.'
        An unexpected error was returned: 'Your submission could not be processed because the token has expired.

        Please push the back button and reload the previous window.'
        An internal error has occurred and the module cannot be displayed.
        There are no results that meet this criteria.
        Search Result for "|||"