Пример #1
0
        /// <summary>
        /// Do thanks row formatting.
        /// </summary>
        private void FormatThanksRow()
        {
            if (!this.Get <YafBoardSettings>().EnableThanksMod)
            {
                return;
            }

            // Register Javascript
            const string AddThankBoxHTML =
                "'<a class=\"yaflittlebutton\" href=\"javascript:addThanks(' + res.d.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + res.d.Title + '><span>' + res.d.Text + '</span></a>'";

            const string RemoveThankBoxHTML =
                "'<a class=\"yaflittlebutton\" href=\"javascript:removeThanks(' + res.d.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + res.d.Title + '><span>' + res.d.Text + '</span></a>'";

            var thanksJs =
                this.Get <IScriptBuilder>().CreateStatement().Add(JavaScriptBlocks.AddThanksJs(RemoveThankBoxHTML)).AddLine().Add(JavaScriptBlocks.RemoveThanksJs(AddThankBoxHTML));

            YafContext.Current.PageElements.RegisterJsBlockStartup("ThanksJs", thanksJs);

            this.Thank.Visible = this.PostData.CanThankPost && !this.PageContext.IsGuest &&
                                 this.Get <YafBoardSettings>().EnableThanksMod;

            if (Convert.ToBoolean(this.DataRow["IsThankedByUser"]))
            {
                this.Thank.NavigateUrl       = "javascript:removeThanks({0});".FormatWith(this.DataRow["MessageID"]);
                this.Thank.TextLocalizedTag  = "BUTTON_THANKSDELETE";
                this.Thank.TitleLocalizedTag = "BUTTON_THANKSDELETE_TT";
            }
            else
            {
                this.Thank.NavigateUrl       = "javascript:addThanks({0});".FormatWith(this.DataRow["MessageID"]);
                this.Thank.TextLocalizedTag  = "BUTTON_THANKS";
                this.Thank.TitleLocalizedTag = "BUTTON_THANKS_TT";
            }

            var thanksNumber = this.DataRow["MessageThanksNumber"].ToType <int>();

            if (thanksNumber == 0)
            {
                return;
            }

            var username =
                this.HtmlEncode(
                    this.Get <YafBoardSettings>().EnableDisplayName
                        ? UserMembershipHelper.GetDisplayNameFromID(this.PostData.UserId)
                        : UserMembershipHelper.GetUserNameFromID(this.PostData.UserId));

            var thanksLabelText = thanksNumber == 1
                                  ? this.Get <ILocalization>().GetText("THANKSINFOSINGLE").FormatWith(username)
                                  : this.Get <ILocalization>().GetText("THANKSINFO").FormatWith(thanksNumber, username);

            this.ThanksDataLiteral.Text =
                "<img id=\"ThanksInfoImage{0}\" src=\"{1}\" alt=\"thanks\"  runat=\"server\" />&nbsp;{2}".FormatWith(
                    this.DataRow["MessageID"],
                    this.Get <ITheme>().GetItem("ICONS", "THANKSINFOLIST_IMAGE"),
                    thanksLabelText);

            this.ThanksDataLiteral.Visible = true;

            this.thanksDataExtendedLiteral.Text    = this.FormatThanksInfo(this.DataRow["ThanksInfo"].ToString());
            this.thanksDataExtendedLiteral.Visible = true;
        }
Пример #2
0
        /// <summary>
        /// Do thanks row formatting.
        /// </summary>
        private void FormatThanksRow()
        {
            if (!this.Get <YafBoardSettings>().EnableThanksMod)
            {
                return;
            }

            if (this.PostData.PostDeleted || this.PostData.IsLocked)
            {
                return;
            }

            // Register Javascript
            const string AddThankBoxHTML =
                "'<a class=\"yaflittlebutton\" href=\"javascript:addThanks(' + res.d.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + res.d.Title + '><span>' + res.d.Text + '</span></a>'";

            const string RemoveThankBoxHTML =
                "'<a class=\"yaflittlebutton\" href=\"javascript:removeThanks(' + res.d.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + res.d.Title + '><span>' + res.d.Text + '</span></a>'";

            var thanksJs = JavaScriptBlocks.AddThanksJs(RemoveThankBoxHTML) + Environment.NewLine + JavaScriptBlocks.RemoveThanksJs(AddThankBoxHTML);

            YafContext.Current.PageElements.RegisterJsBlockStartup("ThanksJs", thanksJs);

            this.Thank.Visible = this.PostData.CanThankPost && !this.PageContext.IsGuest &&
                                 this.Get <YafBoardSettings>().EnableThanksMod;

            if (Convert.ToBoolean(this.DataRow["IsThankedByUser"]))
            {
                this.Thank.NavigateUrl       = "javascript:removeThanks({0});".FormatWith(this.DataRow["MessageID"]);
                this.Thank.TextLocalizedTag  = "BUTTON_THANKSDELETE";
                this.Thank.TitleLocalizedTag = "BUTTON_THANKSDELETE_TT";
            }
            else
            {
                this.Thank.NavigateUrl       = "javascript:addThanks({0});".FormatWith(this.DataRow["MessageID"]);
                this.Thank.TextLocalizedTag  = "BUTTON_THANKS";
                this.Thank.TitleLocalizedTag = "BUTTON_THANKS_TT";
            }

            var thanksNumber = this.DataRow["MessageThanksNumber"].ToType <int>();

            if (thanksNumber == 0)
            {
                return;
            }

            var username =
                this.HtmlEncode(
                    this.Get <YafBoardSettings>().EnableDisplayName
                        ? UserMembershipHelper.GetDisplayNameFromID(this.PostData.UserId)
                        : UserMembershipHelper.GetUserNameFromID(this.PostData.UserId));

            var thanksLabelText = thanksNumber == 1
                                  ? this.Get <ILocalization>().GetText("THANKSINFOSINGLE").FormatWith(username)
                                  : this.Get <ILocalization>().GetText("THANKSINFO").FormatWith(thanksNumber, username);

            this.ThanksDataLiteral.Text =
                "<i class=\"fa fa-heart\" style=\"color:#e74c3c\"></i>&nbsp;{0}".FormatWith(thanksLabelText);

            this.ThanksDataLiteral.Visible = true;

            this.thanksDataExtendedLiteral.Text    = this.FormatThanksInfo(this.DataRow["ThanksInfo"].ToString());
            this.thanksDataExtendedLiteral.Visible = true;
        }
Пример #3
0
        /// <summary>
        /// Do thanks row formatting.
        /// </summary>
        private void FormatThanksRow()
        {
            if (!this.Get <BoardSettings>().EnableThanksMod)
            {
                return;
            }

            if (this.PostData.PostDeleted || this.PostData.IsLocked)
            {
                return;
            }

            // Register Javascript
            var addThankBoxHTML =
                this.PageContext.IsMobileDevice ?
                "'<a class=\"btn btn-link\" href=\"javascript:addThanks(' + response.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + response.Title + '><span><i class=\"fas fa-heart text-danger fa-fw\"></i></span></a>'" :
                "'<a class=\"btn btn-link\" href=\"javascript:addThanks(' + response.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + response.Title + '><span><i class=\"fas fa-heart text-danger fa-fw\"></i>&nbsp;' + response.Text + '</span></a>'";

            var removeThankBoxHTML =
                this.PageContext.IsMobileDevice ?
                "'<a class=\"btn btn-link\" href=\"javascript:removeThanks(' + response.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + response.Title + '><span><i class=\"far fa-heart fa-fw\"></i></a>'" :
                "'<a class=\"btn btn-link\" href=\"javascript:removeThanks(' + response.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + response.Title + '><span><i class=\"far fa-heart fa-fw\"></i>&nbsp;' + response.Text + '</span></a>'";

            var thanksJs = "{0}{1}{2}".Fmt(
                JavaScriptBlocks.AddThanksJs(removeThankBoxHTML),
                Environment.NewLine,
                JavaScriptBlocks.RemoveThanksJs(addThankBoxHTML));

            this.PageContext.PageElements.RegisterJsBlockStartup("ThanksJs", thanksJs);

            this.Thank.Visible = this.PostData.CanThankPost && !this.PageContext.IsGuest &&
                                 this.Get <BoardSettings>().EnableThanksMod;

            if (this.DataRow.Field <bool>("IsThankedByUser"))
            {
                this.Thank.NavigateUrl = $"javascript:removeThanks({this.DataRow["MessageID"]});";

                if (!this.PageContext.IsMobileDevice)
                {
                    this.Thank.Text = this.GetText("BUTTON_THANKSDELETE");
                }

                this.Thank.TitleLocalizedTag = "BUTTON_THANKSDELETE_TT";
                this.Thank.Icon         = "heart";
                this.Thank.IconCssClass = "far";
            }
            else
            {
                this.Thank.NavigateUrl = $"javascript:addThanks({this.DataRow["MessageID"]});";

                if (!this.PageContext.IsMobileDevice)
                {
                    this.Thank.Text = this.GetText("BUTTON_THANKS");
                }

                this.Thank.TitleLocalizedTag = "BUTTON_THANKS_TT";
                this.Thank.Icon         = "heart";
                this.Thank.IconCssClass = "fas";
                this.Thank.IconColor    = "text-danger";
            }

            var thanksNumber = this.DataRow["MessageThanksNumber"].ToType <int>();

            if (thanksNumber == 0)
            {
                return;
            }

            var username = this.HtmlEncode(
                this.Get <BoardSettings>().EnableDisplayName
                    ? UserMembershipHelper.GetDisplayNameFromID(this.PostData.UserId)
                    : UserMembershipHelper.GetUserNameFromID(this.PostData.UserId));

            var thanksLabelText = thanksNumber == 1
                                      ? this.Get <ILocalization>().GetTextFormatted("THANKSINFOSINGLE", username)
                                      : this.Get <ILocalization>().GetTextFormatted(
                "THANKSINFO",
                thanksNumber,
                username);

            this.ThanksDataLiteral.Text = $@"<a class=""btn btn-sm btn-link thanks-popover"" 
                           data-toggle=""popover"" 
                           data-trigger=""click hover""
                           data-html=""true""
                           title=""{thanksLabelText}"" 
                           data-content=""{this.FormatThanksInfo(this.DataRow["ThanksInfo"].ToString()).ToJsString()}"">
                           <i class=""fa fa-heart"" style=""color:#e74c3c""></i>&nbsp;+{thanksNumber}
                  </a>";

            this.ThanksDataLiteral.Visible = true;
        }