コード例 #1
0
        public PageOptionsButtonCollection CloneFields()
        {
            PageOptionsButtonCollection buttonItems = new PageOptionsButtonCollection();

            foreach (PageOptionsButtonItem buttonItem in this)
            {
                buttonItems.Add(buttonItem.CloneAddThisButtonItem());
            }
            return(buttonItems);
        }
コード例 #2
0
        public override void RenderBeginTag(HtmlTextWriter writer)
        {
            #region Var AddThis_Share
            writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
            writer.RenderBeginTag(HtmlTextWriterTag.Script);
            writer.Write("var addthis_share = {\n");
            bool multipleConfigItems = false;
            //title
            if (!string.IsNullOrEmpty(pgInstruction.GetField("add_this_title")))
            {
                if (multipleConfigItems)
                {
                    writer.Write(",\n");
                }
                string titleField = pgInstruction.GetField("add_this_title").Replace("\"", "\\\"");
                writer.Write("title: \"" + titleField + "\"");
                multipleConfigItems = true;
            }
            //description
            if (!string.IsNullOrEmpty(pgInstruction.GetField("add_this_description")))
            {
                if (multipleConfigItems)
                {
                    writer.Write(",\n");
                }
                writer.Write("description: \"" + pgInstruction.GetField("add_this_description") + "\"");
                multipleConfigItems = true;
            }
            //url

            /**if (!pgInstruction.GetUrl("add_this_url").Equals(""))
             * {
             *  if (multipleConfigItems)
             *  {
             *      writer.Write(",\n");
             *  }
             *  writer.Write("url: \"" + pgInstruction.GetUrl("add_this_url") + "\"");
             *  multipleConfigItems = true;
             * }*/
            writer.Write("}");
            writer.RenderEndTag();
            #endregion

            #region Var AddThis_Config
            writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
            writer.RenderBeginTag(HtmlTextWriterTag.Script);
            writer.Write("var addthis_config = {\n");
            multipleConfigItems = false;
            String language = pgInstruction.GetField("Language");
            if (!language.Equals(""))
            {
                PageOptionsButtonLanguageItem langItem = _itemsCollection[language];
                if (langItem != null)
                {
                    //Custom Button Definitions
                    PageOptionsButtonCollection buttonCollection = langItem.ButtonsCollection;
                    if (buttonCollection != null)
                    {
                        bool hasCustomButtons = false;

                        /*foreach (PageOptionsAddThisButtonItem currButton in buttonCollection)
                         * {
                         *
                         *  if (currButton.GetType().Name.Equals("CustomAddThisButtonItem"))
                         *  {
                         *      if (!hasCustomButtons)
                         *      {
                         *          writer.Write("services_custom: {");
                         *          hasCustomButtons = true;
                         *      }
                         *
                         *      bool hasMoreThenOneProperty = false;
                         *      //Name
                         *      if (!string.IsNullOrEmpty(((CustomAddThisButtonItem)currButton).Name))
                         *      {
                         *          writer.Write("name: \"" + ((CustomAddThisButtonItem)currButton).Name + "\"");
                         *          hasMoreThenOneProperty = true;
                         *      }
                         *      //Url
                         *      if (!string.IsNullOrEmpty(((CustomAddThisButtonItem)currButton).Url))
                         *      {
                         *          if (hasMoreThenOneProperty)
                         *          {
                         *              writer.Write(",\n");
                         *          }
                         *          hasMoreThenOneProperty = true;
                         *          writer.Write("url: \"" + ((CustomAddThisButtonItem)currButton).Url + "\"");
                         *      }
                         *      //Icon
                         *      if (!string.IsNullOrEmpty(((CustomAddThisButtonItem)currButton).Icon))
                         *      {
                         *          if (hasMoreThenOneProperty)
                         *          {
                         *              writer.Write(",\n");
                         *          }
                         *          hasMoreThenOneProperty = true;
                         *          writer.Write("icon: \"" + ((CustomAddThisButtonItem)currButton).Icon + "\"");
                         *      }
                         *
                         *  }
                         * }*/
                        if (hasCustomButtons)
                        {
                            writer.Write("}");
                            multipleConfigItems = true;
                        }
                    }
                    //Account Field
                    if (!langItem.Account.Equals(""))
                    {
                        if (multipleConfigItems)
                        {
                            writer.Write(",\n");
                        }
                        writer.Write("username: \"" + langItem.Account + "\"");
                        multipleConfigItems = true;
                    }
                    //Language Field
                    if (!string.IsNullOrEmpty(langItem.Language))
                    {
                        if (multipleConfigItems)
                        {
                            writer.Write(",\n");
                        }
                        writer.Write("ui_language: \"" + langItem.Language + "\"");
                        multipleConfigItems = true;
                    }
                    //Compact Field
                    if (!string.IsNullOrEmpty(langItem.Compact))
                    {
                        if (multipleConfigItems)
                        {
                            writer.Write(",\n");
                        }
                        writer.Write("services_compact: \"" + langItem.Compact + "\"");
                        multipleConfigItems = true;
                    }
                    //Expanded Field
                    if (!string.IsNullOrEmpty(langItem.Expanded))
                    {
                        if (multipleConfigItems)
                        {
                            writer.Write(",\n");
                        }
                        writer.Write("services_expanded: \"" + langItem.Expanded + "\"");
                        multipleConfigItems = true;
                    }
                    //508 compliance
                    if (multipleConfigItems)
                    {
                        writer.Write(",\n");
                    }
                    writer.Write("ui_508_compliant: true");
                }
                writer.Write("}");
                writer.RenderEndTag();
            }
            #endregion

            //writer.AddAttribute(HtmlTextWriterAttribute.Class, "addthis_toolbox addthis_container addthis_default_style addthis_32x32_style");
            base.RenderBeginTag(writer);
        }