/* hider */ (function (window){ var FWDMHider = function(isMobile_bl, screenToTest, hideDelay){ var _s = this; var prototype = FWDMHider.prototype; _s.screenToTest = screenToTest; _s.hideDelay = hideDelay; _s.globalX = 0; _s.globalY = 0; _s.currentTime; _s.checkIntervalId_int; _s.dispatchOnceShow_bl = true; _s.dispatchOnceHide_bl = false; _s.isMobile_bl = isMobile_bl; _s.isStopped_bl = true; _s.hasPointerEvent_bl = FWDMUtils.hasPointerEvent; _s.init = function(){}; _s.start = function(){ _s.currentTime = new Date().getTime(); _s.checkIntervalId_int = setInterval(_s.update, 100); _s.addMouseOrTouchCheck(); _s.isStopped_bl = false; }; _s.stop = function(){ clearInterval(_s.checkIntervalId_int); _s.isStopped_bl = true; _s.removeMouseOrTouchCheck(); }; _s.addMouseOrTouchCheck = function(){ if(_s.isMobile_bl){ if(_s.hasPointerEvent_bl){ _s.screenToTest.screen.addEventListener("MSPointerDown", _s.onMouseOrTouchUpdate); _s.screenToTest.screen.addEventListener("MSPointerMove", _s.onMouseOrTouchUpdate); }else{ _s.screenToTest.screen.addEventListener("touchstart", _s.onMouseOrTouchUpdate); } }else if(_s.screenToTest.screen.addEventListener){ _s.screenToTest.screen.addEventListener("mousemove", _s.onMouseOrTouchUpdate); }else if(_s.screenToTest.screen.attachEvent){ _s.screenToTest.screen.attachEvent("onmousemove", _s.onMouseOrTouchUpdate); } }; _s.removeMouseOrTouchCheck = function(){ if(_s.isMobile_bl){ if(_s.hasPointerEvent_bl){ _s.screenToTest.screen.removeEventListener("MSPointerDown", _s.onMouseOrTouchUpdate); _s.screenToTest.screen.removeEventListener("MSPointerMove", _s.onMouseOrTouchUpdate); }else{ _s.screenToTest.screen.removeEventListener("touchstart", _s.onMouseOrTouchUpdate); } }else if(_s.screenToTest.screen.removeEventListener){ _s.screenToTest.screen.removeEventListener("mousemove", _s.onMouseOrTouchUpdate); }else if(_s.screenToTest.screen.detachEvent){ _s.screenToTest.screen.detachEvent("onmousemove", _s.onMouseOrTouchUpdate); } }; _s.onMouseOrTouchUpdate = function(e){ var viewportMouseCoordinates = FWDMUtils.getViewportMouseCoordinates(e); _s.currentTime = new Date().getTime(); _s.globalX = viewportMouseCoordinates.screenX; _s.globalY = viewportMouseCoordinates.screenY; }; _s.update = function(e){ if(new Date().getTime() > _s.currentTime + _s.hideDelay){ if(_s.dispatchOnceShow_bl){ _s.dispatchEvent(FWDMHider.HIDE); _s.dispatchOnceHide_bl = true; _s.dispatchOnceShow_bl = false; } }else{ if(_s.dispatchOnceHide_bl){ _s.dispatchEvent(FWDMHider.SHOW); _s.dispatchOnceHide_bl = false; _s.dispatchOnceShow_bl = true; } } }; _s.reset = function(){ _s.currentTime = new Date().getTime(); _s.dispatchEvent(FWDMHider.SHOW); }; /* destroy */ _s.destroy = function(){ _s.removeMouseOrTouchCheck(); clearInterval(_s.checkIntervalId_int); _s.screenToTest = null; screenToTest = null; _s.init = null; _s.start = null; _s.stop = null; _s.addMouseOrTouchCheck = null; _s.removeMouseOrTouchCheck = null; _s.onMouseOrTouchUpdate = null; _s.update = null; _s.reset = null; _s.destroy = null; prototype.destroy(); prototype = null; _s = null; FWDMHider.prototype = null; }; _s.init(); }; FWDMHider.HIDE = "hide"; FWDMHider.SHOW = "show"; FWDMHider.setPrototype = function(){ FWDMHider.prototype = new FWDMEventDispatcher(); }; window.FWDMHider = FWDMHider; }(window));