/* FWDMLightBox */ (function (window){ var FWDMLightBox = function( prt, mainBackgroundColor_str, holderBackgroundColor_str, lightBoxBackgroundOpacity, lightBoxWidth, lightBoxHeight ){ var _s = this; var prototype = FWDMLightBox.prototype; _s.mainLightBox_do = null; _s.lightBoxBackground_sdo = null; _s.lightBoxGridHolder_do = null; _s.closeButton_do = null; _s.mainBackgroundColor_str = mainBackgroundColor_str; _s.holderBackgroundColor_str = holderBackgroundColor_str; _s.lightBoxBackgroundOpacity = lightBoxBackgroundOpacity; _s.lightBoxWidth = lightBoxWidth; _s.lightBoxHeight = lightBoxHeight; _s.setupButtonWithDelayId_to; _s.isMobile_bl = FWDMUtils.isMobile; _s.hasPointerEvent_bl = FWDMUtils.hasPointerEvent; _s.closeButtonIsTweening_bl = true; _s.init = function(){ _s.getStyle().zIndex = 9999999; _s.setupMainContainers(); }; //#############################################// /* setup main containers */ //#############################################// _s.setupMainContainers = function(){ var viewportSize = FWDMUtils.getViewportSize(); _s.viewportSize = viewportSize; var scrollOffsets = FWDMUtils.getScrollOffsets(); if(_s.isMobile_bl && _s.hasPointerEvent_bl) _s.getStyle().msTouchAction = "none"; _s.setWidth(viewportSize.w); _s.setHeight(viewportSize.h); _s.setX(scrollOffsets.x); _s.setY(scrollOffsets.y); _s.lightBoxBackground_sdo = new FWDMSimpleDisplayObject("div"); _s.lightBoxBackground_sdo.setResizableSizeAfterParent(); _s.lightBoxBackground_sdo.setBkColor(_s.mainBackgroundColor_str); _s.addChild(_s.lightBoxBackground_sdo); _s.mainLightBox_do = new FWDMDisplayObject("div"); //_s.mainLightBox_do.getStyle().boxShadow = "0px 0px 5px #999999"; _s.mainLightBox_do.setBkColor(_s.holderBackgroundColor_str); prt.stageContainer = _s.mainLightBox_do.screen; _s.addChild(_s.mainLightBox_do); if(navigator.userAgent.toLowerCase().indexOf("msie 7") == -1){ document.documentElement.appendChild(_s.screen); }else{ document.getElementsByTagName("body")[0].appendChild(_s.screen); } _s.lightBoxBackground_sdo.setAlpha(0); FWDAnimation.to(_s.lightBoxBackground_sdo, .8, {alpha:_s.lightBoxBackgroundOpacity}); _s.setX(scrollOffsets.x); _s.setY(scrollOffsets.y); _s.mainLightBox_do.setWidth(0); _s.mainLightBox_do.setHeight(0); _s.mainLightBox_do.setX(parseInt(viewportSize.w/2)); _s.mainLightBox_do.setY(parseInt(viewportSize.h/2)); if(_s.lightBoxWidth > viewportSize.w){ _s.finalLightBoxWidth = viewportSize.w; _s.finalLightBoxHeight = parseInt(_s.lightBoxHeight * (viewportSize.w/_s.lightBoxWidth)); }else{ _s.finalLightBoxWidth = _s.lightBoxWidth; _s.finalLightBoxHeight = _s.lightBoxHeight; } FWDAnimation.to(_s.mainLightBox_do, .8, { w:_s.finalLightBoxWidth, h:_s.finalLightBoxHeight, x:parseInt((viewportSize.w - _s.finalLightBoxWidth)/2), y:parseInt((viewportSize.h - _s.finalLightBoxHeight)/2), delay:.4, ease:Expo.easeInOut}); }; //#############################################// /* setup lightbox close button */ //#############################################// _s.setupCloseButton = function(n_img, s_img){ FWDMSimpleButton.setPrototype(); if(prt._d.useVectorIcons){ _s.closeButton_do = new FWDMSimpleButton( 0, 0, "", "fwdm-skin-vector-close-button-icon-normal", "fwdm-skin-vector-close-button-icon-selected" ); }else{ _s.closeButton_do = new FWDMSimpleButton(n_img, s_img); } _s.closeButton_do.setX(-200); if(prt._d.useVectorIcons){ setTimeout(function(){ if(_s == null) return; _s.showCloseButton(); }, 360); }else{ _s.showCloseButton(); } _s.closeButton_do.addListener(FWDMSimpleButton.MOUSE_DOWN, _s.closeButtonOnStartHandler); _s.addChild(_s.closeButton_do); if(_s.isMobile_bl){ if(!_s.hasPointerEvent_bl){ window.addEventListener("touchstart", _s.mouseDummyHandler); window.addEventListener("touchmove", _s.mouseDummyHandler); } }else{ if(window.addEventListener){ window.addEventListener ("mousewheel", _s.mouseDummyHandler); window.addEventListener('DOMMouseScroll', _s.mouseDummyHandler); }else if(document.attachEvent){ document.attachEvent("onmousewheel", _s.mouseDummyHandler); } } }; _s.showCloseButton = function(){ window.addEventListener("keyup", _s.onKeyUpHandler); var viewportSize = FWDMUtils.getViewportSize(); var closeButtonFinalX = parseInt((viewportSize.w + _s.finalLightBoxWidth)/2 - _s.closeButton_do.totalWidth/2); var closeButtonFinalY = parseInt((viewportSize.h - _s.finalLightBoxHeight)/2 - _s.closeButton_do.totalHeight/2); closeButtonFinalX = viewportSize.w - _s.closeButton_do.totalWidth - 10; closeButtonFinalY = 10; _s.closeButton_do.setX(viewportSize.w); _s.closeButton_do.setY(closeButtonFinalY); FWDAnimation.to(_s.closeButton_do, .9, {x:closeButtonFinalX, onComplete:_s.showCloseButtonComplete, ease:Expo.easeInOut}); } _s.onKeyUpHandler = function(e){ if(e.keyCode == 27){ _s.closeButtonOnStartHandler(); } } _s.showCloseButtonComplete = function(){ _s.closeButtonIsTweening_bl = false; } _s.mouseDummyHandler = function(e){ if(e.preventDefault){ e.preventDefault(); }else{ return false; } }; _s.closeButtonOnStartHandler = function(e){ var viewportSize = FWDMUtils.getViewportSize(); _s.closeButton_do.isDisabled_bl = true; FWDAnimation.to(_s.closeButton_do, .9, {x:viewportSize.w, ease:Expo.easeInOut}); FWDAnimation.to(_s.mainLightBox_do, .8, { w:0, h:0, x:parseInt(viewportSize.w/2), y:parseInt(viewportSize.h/2), delay:.4, ease:Expo.easeInOut}); FWDAnimation.to(prt.main_do, .8, { x:parseInt(-prt.main_do.w/2), y:parseInt(-prt.main_do.h/2), delay:.4, ease:Expo.easeInOut}); FWDAnimation.to(_s.lightBoxBackground_sdo, .8, {alpha:0, delay:.8}); _s.lighboxAnimDoneId_to = setTimeout(_s.lighboxHideAnimationDone, 1600); window.removeEventListener("keyup", _s.onKeyUpHandler); _s.dispatchEvent(FWDMLightBox.CLOSE); }; _s.lighboxHideAnimationDone = function(){ _s.dispatchEvent(FWDMLightBox.HIDE_COMPLETE); }; //#####################################// /* destroy */ //####################################// _s.destroy = function(){ try{ if(navigator.userAgent.toLowerCase().indexOf("msie 7") == -1){ document.documentElement.removeChild(_s.screen); }else{ document.getElementsByTagName("body")[0].removeChild(_s.screen); } }catch(e){} if(_s.isMobile_bl){ if(!_s.hasPointerEvent_bl){ window.removeEventListener("touchstart", _s.mouseDummyHandler); window.removeEventListener("touchmove", _s.mouseDummyHandler); } }else{ if(window.removeEventListener){ window.removeEventListener ("mousewheel", _s.mouseDummyHandler); window.removeEventListener('DOMMouseScroll', _s.mouseDummyHandler); }else if(document.detachEvent){ document.detachEvent("onmousewheel", _s.mouseDummyHandler); } } clearTimeout(_s.lighboxAnimDoneId_to); if(_s.lightBoxBackground_sdo){ FWDAnimation.killTweensOf(_s.lightBoxBackground_sdo); _s.lightBoxBackground_sdo.destroy(); } if(_s.lightBoxGridHolder_do){ FWDAnimation.killTweensOf(_s.lightBoxGridHolder_do); _s.lightBoxGridHolder_do.destroy(); } if(_s.closeButton_do){ FWDAnimation.killTweensOf(_s.closeButton_do); _s.closeButton_do.destroy(); } _s.mainLightBox_do = null; _s.lightBoxBackground_sdo = null; _s.lightBoxGridHolder_do = null; _s.closeButton_do = null; _s.mainBackgroundColor_str = null; _s.holderBackgroundColor_str = null; prt = null; mainBackgroundColor_str = null; holderBackgroundColor_str = null; _s.setInnerHTML(""); prototype.destroy(); _s = null; prototype = null; FWDMLightBox.prototype = null; }; _s.init(); }; /* set prototype */ FWDMLightBox.setPrototype = function(){ FWDMLightBox.prototype = new FWDMDisplayObject("div"); }; FWDMLightBox.CLOSE = "ligtBoxClose"; FWDMLightBox.HIDE_COMPLETE = "hideComplete"; FWDMLightBox.prototype = null; window.FWDMLightBox = FWDMLightBox; }(window));