Esempio n. 1
0
        /// <summary> returns tooltipcontainer and tooltip</summary>
        private Tuple <HTMLElement, HTMLElement> GetOrCreateTooltipOn(HTMLElement tooltipOn, string content, TooltipMode mode)
        {
            if (_tooltips.ContainsKey(tooltipOn))
            {
                var oldTt = _tooltips.Get(tooltipOn).Item1;
                oldTt.TextContent = content;
                return(Tuple.Create(oldTt.ParentElement, oldTt));
            }

            //tooltips need to be in container so that relative positioning works in both:
            //inline scenario: <label><input><tooltip> and in
            //'display:table' scenario those three have "display: table-cell"
            var ttCont = Document.CreateElement("span");

            ttCont.ClassName = Magics.CssClassTooltipContainer;

            var tt = Document.CreateElement("span");

            tt.Id          = UniqueIdGenerator.GenerateAsString();
            tt.TextContent = content;
            tt.ClassName   = Magics.CssClassTooltip;
            tt.ClassList.Add(Magics.CssClassDisabled);

            ttCont.AppendChild(tt);

            Logger.Debug(GetType(), "created tooltip to show it {0}", tt.Id);
            _tooltips[tooltipOn] = Tuple.Create(tt, mode);

            return(Tuple.Create(ttCont, tt));
        }
        public static void Unrender(this IFormCanvas <HTMLElement> self)
        {
            Logger.Debug(typeof(FormCanvasExtensions), "Unrender()");
            var handlers = Handlers.Get(self);

            self.Hide();

            if (handlers.OnUserCancel != null)
            {
                self.UserCancel = handlers.OnUserCancel;
            }

            Handlers.Delete(self);
        }
Esempio n. 3
0
        public MouseObserver()
        {
            Document.AddEventListener("mousedown", rawEv => {
                var ev = (MouseEvent)rawEv;

                Document.Body.TraverseAll(el => {
                    if (!el.IsMouseEventRecipient())
                    {
                        return(false);
                    }

                    if (!_mouseDownListeners.ContainsKey(el))
                    {
                        return(false);
                    }
                    Logger.Debug(GetType(), "invoking mousedown listener");
                    _mouseDownListeners.Get(el)(ev);
                    return(true);
                });
            });

            Document.AddEventListener("mouseup", rawEv => {
                var ev = (MouseEvent)rawEv;

                Document.Body.TraverseAll(el => {
                    if (!el.IsMouseEventRecipient())
                    {
                        return(false);
                    }

                    if (!_mouseUpListeners.ContainsKey(el))
                    {
                        return(false);
                    }
                    Logger.Debug(GetType(), "invoking mouseup listener");
                    _mouseUpListeners.Get(el)(ev);
                    return(true);
                });
            });

            Document.AddEventListener("click", rawEv => {
                var ev = (MouseEvent)rawEv;

                Document.Body.TraverseAll(el => {
                    if (!el.IsMouseEventRecipient())
                    {
                        return(false);
                    }

                    if (!_mouseClickListeners.ContainsKey(el))
                    {
                        return(false);
                    }
                    Logger.Debug(GetType(), "invoking mouseup listener");
                    _mouseClickListeners.Get(el)(ev);
                    return(true);
                });
            });

            Document.AddEventListener("mousemove", ev => {
                Document.Body.TraverseAll(el => {
                    if (!el.IsMouseEventRecipient())
                    {
                        return(false);
                    }

                    if (!_mouseMoveListeners.ContainsKey(el))
                    {
                        return(false);
                    }

                    //Logger.Debug(GetType(), "invoking mousemove listener");
                    _mouseMoveListeners.Get(el)((MouseEvent)ev);
                    return(true);
                }, Magics.PurposeMouseMove);
            });
        }