[CLOSED] Image Caption: Film Layer

  1. #1

    [CLOSED] Image Caption: Film Layer

    Attached Thumbnails Click image for larger version. 

Name:	car01.jpg 
Views:	7 
Size:	54.9 KB 
ID:	22231   Click image for larger version. 

Name:	car03.jpg 
Views:	6 
Size:	85.9 KB 
ID:	22241  
    Last edited by Daniil; Mar 10, 2015 at 5:35 AM. Reason: [CLOSED]
  2. #2
    Hi Chris,

    IE7 does not like horizontal ruler within the HTML.
    Please try to change the caption to
    string caption = String.Format("<span style='float: right'><i>{1}</i></span><b>{0}</b><hr />{2}", myImage.Title, myImage.Credit, myImage.Caption);
    Credits to this Stackoverflow thread.

    Also please use this styling.
    <style>
        .imageTooltip {
            background-color: #000000;
            opacity: 0.80;
            filter: Alpha(opacity=80);
        }
    
        .imageTooltipBody {
            padding: 5px 7px 5px 7px;
            font-size: 11px;
            color: #FFFFFF;
        }
    
        .x-ie7 .imageTooltip table.x-table-plain {
            width: 100%; 
        }
    </style>
    The FilmLayer works very nicely when the card layout switches to the next image in Chrome and Firefox, but in IE the tooltip will not change until I move off the image and then back on. Question: Any thoughts?
    Probably, for some reason IE doesn't refire an event (like MouseOver or MouseEnter) that triggers a ToolTip as Chrome and Firefox do.

    I can suggest to re-show a ToolTip manually:
    Ext.define("MyOverrides", {
        override: "Ext.layout.CardLayout",
    
        nextImage: function () {
            var oldCard = this.activeItem,
                oldFilmLayer = Ext.getCmp("Layer" + oldCard.tag),
                oldToolTip = Ext.getCmp("ToolTip_" + oldCard.id),
                reshowToolTip = Ext.isIE && oldToolTip.isVisible();
    
            oldFilmLayer.hide();
    
            var newCard = this.activeItem.next() || this.owner.items.getAt(0),
                newFilmLayer = Ext.getCmp("Layer" + newCard.tag);
    
            this.setActiveItem(newCard);
            newFilmLayer.show();
            newCard.updateLayout();
    
            if (reshowToolTip) {
                oldToolTip.hide();
                Ext.getCmp("ToolTip_" + newCard.id).show();
            }
        }
    });
    You might want to enable this functionality for Chrome and Firefox as well by removing Ext.isIE &&.
  3. #3
    I didn't originally find that Stackoverflow thread. Very interesting solution.

    Appreciate the suggestion for re-showing the tooltips. It is so smooth now, looks great. Thank you very much for polishing this up.

    Question: One last minor question would be when I move the mouse over the image (layer) the tooltip is shown. If I then click on the image the tooltip disappears. Is there a way to cancel the mouse click to stop the tooltip from hiding?

    Final code example, implementing your suggestions. Hope this helps someone else.


    Associated Images: Click image for larger version. 

Name:	car01.jpg 
Views:	7 
Size:	54.9 KB 
ID:	22231 Click image for larger version. 

Name:	car03.jpg 
Views:	6 
Size:	85.9 KB 
ID:	22241

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <script runat="server">
        public class MyImage
        {
            public string Filename { get; set; }
            public string Title { get; set; }
            public string Credit { get; set; }
            public string Caption { get; set; }
            public DateTime DateAdded { get; set; }
            public Boolean Active { get; set; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            List<MyImage> images = GetImages();
            int imageIndex = 0;
    
            foreach (MyImage myImage in images)
            {
                imageIndex++;
                String imageUrl = String.Format("images/{0}", myImage.Filename);
                String id = String.Format("Image{0}", imageIndex);
    
                Ext.Net.Image img = new Ext.Net.Image
                {
                    ID = id,
                    ImageUrl = imageUrl,
                    Tag = imageIndex,
                    Width = 480
                };
    
                String lId = String.Format("Layer{0}", imageIndex);
                Container ctnr = new Container
                {
                    ID = lId,
                    // Add background-color: red; opacity: 0.2; filter:Alpha(opacity=20); to style below to see the filmLayer.
                    // IE9 and belows require the background-color and filter:Alpha(opacity=0) to show a tooltip or it could be a z-index issue.
                    StyleSpec = "position: absolute; z-index: 20000; background-color: red; opacity: 0.0; filter:Alpha(opacity=0);",
                    CustomConfig = { new ConfigItem { Name = "layerTargetID", Value = id, Mode = ParameterMode.Value } },
                    Listeners = { AfterLayout = { Fn = "ApplyPanel" } }
                };
                if (imageIndex > 1) ctnr.Hidden = true;
    
                string caption = String.Format("<span style='float: right'><i>{1}</i></span><b>{0}</b><hr/>{2}", myImage.Title, myImage.Credit, myImage.Caption);
                String tId = String.Format("ToolTip{0}", imageIndex);
                ToolTip tt = new ToolTip
                {
                    ID = tId,
                    MaxWidth = 479,
                    Width = 479,
                    DismissDelay = 0,
                    Html = caption,
                    BaseCls = "imageTooltip",
                    BodyCls = "imageTooltipBody",
                    CustomConfig = { new ConfigItem { Name = "getTargetXY", Value = "getConstrainedTipXY", Mode = ParameterMode.Raw } }
                };
                ctnr.ToolTips.Add(tt);
    
                ImageCarousel.Items.Add(img);
                ImageCarousel.ContentControls.Add(ctnr);
            };
        }
    
        private List<MyImage> GetImages()
        {
            List<MyImage> data = new List<MyImage>();
    
            data.Add(new MyImage { Filename = "car03.jpg", Title = "BLUE COLD", Credit = "2010 Ford Mustang At SEMA 2009", Caption = "Blah", DateAdded = DateTime.Parse("2015-01-01"), Active = true });
            data.Add(new MyImage { Filename = "car01.jpg", Title = "RED HOT", Credit = "Photo taken from niceartpaperz.com", Caption = "Blah", DateAdded = DateTime.Parse("2015-01-01"), Active = true });
    
            return data;
        }
    
    </script>
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            var getConstrainedTipXY = function () {
                //imageDom = this.target.dom;
                //tooltipDom = this.el.dom;
                //coordX = imageDom.clientLeft;
                //coordY = imageDom.clientTop + imageDom.clientHeight - (tooltipDom.clientTop + tooltipDom.clientHeight)
                //return [coordX, coordY];
    
                var me = this,
                    offsets, xy, dh, dw, de, bd, scrollX, scrollY, axy, sz;
                imageDom = me.target.dom;
                tooltipDom = this.el.dom;
    
                xy = me.getAlignToXY(me.target, 'tl-bl');
                dw = Ext.Element.getViewWidth() - 5;
                dh = Ext.Element.getViewHeight() - 5;
                de = document.documentElement;
                bd = document.body;
                scrollX = (de.scrollLeft || bd.scrollLeft || 0) + 5;
                scrollY = (de.scrollTop || bd.scrollTop || 0) + 5; tooltipSz = me.getSize();
                if (xy[1] - tooltipSz.height > dh)
                    return [xy[0], xy[1] - imageDom.clientHeight];
                else
                    return [xy[0], xy[1] - (tooltipDom.clientTop + tooltipDom.clientHeight)];
            };
    
            var ApplyPanel = function (layer) {
                var target = Ext.getCmp(layer.layerTargetID);
                var targetDom = target.el.dom;
                var myDom = layer.el.dom;
                myDom.style.top = targetDom.clientTop + "px";
                myDom.style.left = targetDom.clientLeft + "px";
                myDom.style.width = targetDom.clientWidth + "px";
                myDom.style.height = targetDom.clientHeight + "px";
            };
    
            Ext.define("MyOverrides", {
                override: "Ext.layout.CardLayout",
    
                nextImage: function () {
                    var oldCard = this.activeItem,
                        oldFilmLayer = Ext.getCmp("Layer" + oldCard.tag),
                        oldToolTip = Ext.getCmp("ToolTip" + oldCard.tag);
    
                    reshowToolTip = oldToolTip.isVisible();
    
                    oldFilmLayer.hide();
    
                    var newCard = this.activeItem.next() || this.owner.items.getAt(0),
                        newFilmLayer = Ext.getCmp("Layer" + newCard.tag);
    
                    this.setActiveItem(newCard);
                    newFilmLayer.show();
                    newCard.updateLayout();
    
                    if (reshowToolTip) {
                        oldToolTip.hide();
                        Ext.getCmp("ToolTip" + newCard.tag).show();
                    }
                }
            });
        </script>
        <style>
            .imageTooltip {
                background-color: #000000;
                opacity: 0.80;
                filter: Alpha(opacity=80);
            }
    
            .imageTooltipBody {
                padding: 5px 7px 5px 7px;
                font-size: 11px;
                color: #FFFFFF;
            }
    
            .x-ie7 .imageTooltip table.x-table-plain {
                width: 100%;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server" ScriptMode="Debug" SourceFormatting="true" />
            <ext:Panel runat="server" Layout="HBoxLayout" Width="600">
                <LayoutConfig>
                    <ext:HBoxLayoutConfig Align="Stretch" DefaultMargins="3" />
                </LayoutConfig>
                <Items>
                    <ext:Panel runat="server" Html="Filler" Flex="1" />
                    <ext:Panel ID="ImageCarousel" runat="server" Width="480" Height="294" Layout="CardLayout">
                        <Bin>
                            <ext:TaskManager ID="ImageCarouselTaskManager" runat="server" ClientIDMode="Static"
                                AutoRunDelay="4000">
                                <Tasks>
                                    <ext:Task TaskID="ImageCarouselTask" Interval="4000" AutoRun="true">
                                        <Listeners>
                                            <Update Handler="App.ImageCarousel.layout.nextImage();" />
                                        </Listeners>
                                    </ext:Task>
                                </Tasks>
                            </ext:TaskManager>
                        </Bin>
                    </ext:Panel>
                </Items>
            </ext:Panel>
        </form>
    </body>
    </html>
    Last edited by cwolcott; Mar 09, 2015 at 2:21 AM.
  4. #4
    Please try to add this ConfigItem for the ToolTips:
    new ConfigItem
    {
        Name = "onDocMouseDown",
        Value = "Ext.emptyFn",
        Mode = ParameterMode.Raw
    }
    or to use this override:
    Ext.tip.ToolTip.override({
        onDocMouseDown: function(e) {
            var me = this;
            if (!me.closable && !e.within(me.el.dom) && !e.within(me.target)) {
                me.disable();
                Ext.defer(me.doEnable, 100, me);
            }
        }
    });
  5. #5
    I used the ConfigItem code and it worked great for all versions of IE.

    Please close the thread.

Similar Threads

  1. [CLOSED] Image Caption
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 06, 2015, 9:22 AM
  2. [CLOSED] Is it possible to add back layer for ext:Image?
    By livehealthierGF in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: May 02, 2013, 4:12 PM
  3. [2.2.1]Ext 3 compatibility layer
    By qdano in forum 2.x Help
    Replies: 1
    Last Post: Apr 02, 2013, 3:58 AM
  4. how to set gridpanel RowEditor layer z-index ,
    By new163_2 in forum 1.x Help
    Replies: 0
    Last Post: Jun 24, 2011, 8:56 AM
  5. [CLOSED] Load Mask Caption using GridPanel
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 01, 2011, 6:35 AM

Posting Permissions