private void SetImageProperties(Asset asset)
        {
            ImageUrl = Page.ResolveClientUrl(AssetFileUrlHelper.GetThumbnailUrl(asset.AssetId.GetValueOrDefault()));

            if (UseCacheBuster)
            {
                ImageUrl += string.Format("?cb={0}", DateTime.Now.Ticks);
            }

            if (ImageLinksToAssetInfo)
            {
                NavigateUrl = SiteUtils.GetShowAssetInfoUrl(asset.AssetId.GetValueOrDefault());
            }

            if (ShowInfoOnHover)
            {
                string captionTitle = SiteUtils.GetAssetHoverCaption(asset, HoverCaption);
                string captionText  = SiteUtils.GetAssetHoverText(asset, HoverText);

                if (!asset.IsPublishedAndAvailable())
                {
                    captionText += "<br/><br/>";

                    if (asset.PublishDate > DateTime.Now)
                    {
                        captionText += "<strong style='color:red'>Asset publish date is in the future</strong><br/>";
                    }

                    if (asset.ExpiryDate < DateTime.Now)
                    {
                        captionText += "<strong style='color:red'>Asset has expired</strong><br/>";
                    }

                    if (asset.AssetPublishStatus != AssetPublishStatus.Published)
                    {
                        captionText += "<strong style='color:red'>Asset is not published</strong><br/>";
                    }
                }

                captionTitle = SiteUtils.MakeJsSafe(captionTitle).Replace("\\n", "<br/>");
                captionText  = SiteUtils.MakeJsSafe(captionText).Replace("\\n", "<br/>");

                string       onmouseover = string.Format("showToolTip('{0}', '{1}')", captionTitle, captionText);
                const string onmouseout  = "hideToolTip();";

                Attributes.Add("onmouseover", onmouseover);
                Attributes.Add("onmouseout", onmouseout);
            }
        }
Example #2
0
        protected void SearchResultListRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case (ListItemType.Item):
            case (ListItemType.AlternatingItem):

                Asset asset = (Asset)e.Item.DataItem;

                AssetButtons AssetButtons1       = (AssetButtons)e.Item.FindControl("AssetButtons1");
                Image        FileTypeIconImage   = (Image)e.Item.FindControl("FileTypeIconImage");
                HyperLink    ReferenceHyperLink  = (HyperLink)e.Item.FindControl("ReferenceHyperLink");
                HyperLink    TitleHyperLink      = (HyperLink)e.Item.FindControl("TitleHyperLink");
                Label        ProductionDateLabel = (Label)e.Item.FindControl("ProductionDateLabel");
                Label        FileSizeLabel       = (Label)e.Item.FindControl("FileSizeLabel");
                Label        AssetTypeLabel      = (Label)e.Item.FindControl("AssetTypeLabel");

                AssetButtons1.LightboxId = PersistentCartLightbox.SelectedLightboxId;
                AssetButtons1.Initialise(asset);

                FileTypeIconImage.ImageUrl = SiteUtils.GetFileTypeImageUrl(asset.FileExtension);
                FileTypeIconImage.ToolTip  = asset.Filename;

                ReferenceHyperLink.Text        = asset.AssetId.ToString();
                ReferenceHyperLink.NavigateUrl = SiteUtils.GetShowAssetInfoUrl(asset.AssetId.GetValueOrDefault());
                TitleHyperLink.Text            = asset.Title;
                TitleHyperLink.NavigateUrl     = ReferenceHyperLink.NavigateUrl;
                ProductionDateLabel.Text       = asset.GetProductionDate();
                FileSizeLabel.Text             = FileUtils.FriendlyFileSize(asset.FileSize);
                AssetTypeLabel.Text            = asset.AssetType.Name;

                string caption = SiteUtils.MakeJsSafe(SiteUtils.GetAssetHoverCaption(asset, string.Empty));
                string text    = SiteUtils.MakeJsSafe(SiteUtils.GetAssetHoverText(asset, string.Empty));

                TitleHyperLink.Attributes["OnMouseOver"] = string.Format("showToolTip('{0}', '{1}')", caption, text);
                TitleHyperLink.Attributes["OnMouseOut"]  = "hideToolTip()";

                if (StringUtils.IsBlank(TitleHyperLink.Text))
                {
                    TitleHyperLink.Text      = "not available";
                    TitleHyperLink.CssClass += " Italics";
                }

                break;
            }
        }