Ejemplo n.º 1
0
        private Control CreateShareDialog()
        {
            string title       = HttpUtility.UrlPathEncode(DocumentExtensions.GetMetaPropertyValue("og:title"));
            string description = HttpUtility.UrlPathEncode(DocumentExtensions.GetMetaPropertyValue("og:description"));
            string image       = HttpUtility.UrlEncode(DocumentExtensions.GetMetaPropertyValue("og:image"));
            string url         = HttpUtility.UrlEncode("http://git.io/numbers");

            Control dialog = new Control("dialog", "share");

            int top = 0;

            foreach (ShareService shareService in ShareServices)
            {
                Control buttonImage = new Control("share-button-image");
                buttonImage.HtmlElement.Style.BackgroundPosition = String.Format("{0}px 0px", -32 * shareService.ImageIndex);

                Control button = new Control("share-button")
                {
                    buttonImage,
                    new Label("share-button-label")
                    {
                        Text = shareService.Header
                    }
                };

                string shareServiceHeader = shareService.Header;
                string shareServiceUrl    = String.Format(shareService.UrlFormat, url, title, description, image);

                button.HtmlElement.AddEventListener("click", () =>
                {
                    statistics.ReportShare(shareServiceHeader);
                    Window.Open(shareServiceUrl);
                });

                button.Top = top;
                top       += 40;

                dialog.AppendChild(button);
            }
            ;

            return(dialog);
        }
Ejemplo n.º 2
0
        public ToolsView(IDialogContainer dialogContainer, Statistics statistics) :
            base("tools-panel")
        {
            this.dialogContainer = dialogContainer;
            this.statistics      = statistics;

            isVisible = true;

            permalinkElement             = Document.CreateElement("a");
            permalinkElement.ClassName   = "permalink";
            permalinkElement.TextContent = "permalink";

            likeButton = new Control("fb-like");
            likeButton.HtmlElement.SetAttribute("data-href", DocumentExtensions.GetMetaPropertyValue("og:url"));
            likeButton.HtmlElement.SetAttribute("data-layout", "standard");
            likeButton.HtmlElement.SetAttribute("data-action", "like");
            likeButton.HtmlElement.SetAttribute("data-show-faces", "true");
            likeButton.HtmlElement.SetAttribute("data-share", "false");

            Label shareLabel = new Label("share-label")
            {
                Text = "\u2764 share"
            };
            Label aboutLabel = new Label("about-label")
            {
                Text = "about"
            };

            shareLabel.HtmlElement.AddEventListener("mousedown", OnShareMouseDown, false);
            aboutLabel.HtmlElement.AddEventListener("mousedown", OnAboutMouseDown, false);

            this.AppendChild(likeButton);
            this.HtmlElement.AppendChild(permalinkElement);
            this.AppendChild(shareLabel);
            this.AppendChild(aboutLabel);
        }