Beispiel #1
0
        private void HideTooltipOn(HTMLElement tooltipOn)
        {
            Logger.Debug(GetType(), "HideTooltipOn on element id={0}", tooltipOn.Id);

            if (!_tooltips.ContainsKey(tooltipOn))
            {
                Logger.Debug(GetType(), "tooltip hide ignored as there's no tooltip assigned");
                return;
            }

            var tt = _tooltips[tooltipOn].Item1;

            Logger.Debug(GetType(), "HideTooltipOn tt id={0}", tt.Id);

            var ops = new List <TooltipOper>();

            _pendingTooltipOps[tt] = ops;

            switch (GetTooltipState(tt))
            {
            case TooltipState.Disabled: break;     //already in the right state

            case TooltipState.EnabledShown:
                ops.AddRange(
                    Lasting(Magics.CssClassActive, Magics.CssClassInactive, Magics.TooltipFadeOutMs),
                    Immediate(Magics.CssClassInactive, Magics.CssClassDisabled));
                break;

            case TooltipState.EnabledHidden:     //interrupted showning or hiding
                ops.Add(Immediate(Magics.CssClassInactive, Magics.CssClassDisabled));
                break;
            }

            ScheduleNextOperation(tt);
        }
Beispiel #2
0
        public SpecificChildListChangedObserver()
        {
            _observer = new MutationObserver((changes, _) => {
                Logger.Debug(GetType(), "[SpecificChildListChangedObserver] dom nodes mutation detected - got {0} items", changes.Length);
                var triggered = 0;
                changes.ForEach(change =>
                                change.AddedNodes
                                .Where(x => x.NodeType == NodeType.Element)
                                .Select(x => x.AsElementOrNull())
                                .ForEach(added =>
                                         triggered += added.TraverseAll(el => {
                    if (!_onAddedListeners.ContainsKey(el))
                    {
                        return(false);
                    }
                    _onAddedListeners[el].ForEach(x => x());
                    return(true);
                }))
                                );
                Logger.Debug(GetType(), "triggered {0} listeners", triggered);
            });

            _observer.Observe(Document.Body, new MutationObserverInit {
                Subtree   = true,
                ChildList = true
            });
        }
Beispiel #3
0
        public SpecificResizeObserver()
        {
            Window.AddEventListener(
                "resize",
                () => {
                Logger.Debug(GetType(), "[SpecificResizeObserver] updating listeners?");
                var updated = Document.Body.TraverseAll(x => {
                    if (!x.IsResizeRecipient() || !_listeners.ContainsKey(x))
                    {
                        return(false);
                    }
                    _listeners[x]();
                    return(true);
                });

                Logger.Debug(GetType(), "updated {0} listeners", updated);
            }
                );
        }
Beispiel #4
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);
            });
        }